Skip to content

Conversation

@DigitalCodeCrafter
Copy link

@DigitalCodeCrafter DigitalCodeCrafter commented Nov 25, 2025

Closes #3158
This PR implements the assertrange <min> <max> opcode as proposed in the linked issue.
It validates that the value on top of the stack is within the specified range without consuming it.
It throws an exception if it is called with an empty stack, the value isn't a Scalar, or the value lies outside of the specified range (inclusive on both sides).

The min and max fields can be any two doubles.
A coercion using Convert.ToDouble(..) is made to allow for integer inputs.
if PseudoNull is used as an argument, the range will be open.
It does not validate that min is smaller than max.

The kerboscript compiler hasn't been altered and this feature is only accessible through manual / external compilation.
This addition is backward compatible and changes no underlying behavior.

This PR does not yet implement the optional open range behavior.

min max allowed
0 10 0.0, ..., 10.0
-1 0 -1.0, ..., 0.0
5.5 6.0 5.5, ..., 6.0
PseudoNull 0 -∞, ..., 0.0
0 PseudoNull 0.0, ..., ∞
PseudoNull PseudoNull -∞, ..., ∞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add range assetion instruction for quick parameter validation

1 participant