untoldwind / KontrolSystem2

Autopilot scripting system for KSP2
Other
54 stars 15 forks source link

Complete ternary expression creates an Option #160

Closed versvisa closed 5 months ago

versvisa commented 5 months ago

Version: 0.5.7.9

On the REPL: (if (1 < 0) 12 else 34).to_string()

Expected result: "34"

Actual result:

KontrolSystem.TO2.Runtime.REPLException: <inline>(1, 24): Type 'Option<int>' does not have a method or field 'to_string'
  at KontrolSystem.TO2.AST.MethodCall.Eval (KontrolSystem.TO2.Runtime.REPLContext context) [0x0037c] in <1dc95836ef154e7482cf2c01ca73c2e8>:0
  at KontrolSystem.TO2.AST.Block+REPLBlockEval.PollValue () [0x0002d] in <1dc95836ef154e7482cf2c01ca73c2e8>:0
  at KontrolSystem.KSP.Runtime.KSPUI.Builtin.REPLExpression.Run (System.String expression) [0x0011d] in <aa4b85f6cc974d628372a13d00851de8>:0
  at KontrolSystem.KSP.Runtime.KSPUI.Builtin.ConsoleWindow.OnRunCommand () [0x0005a] in <aa4b85f6cc974d628372a13d00851de8>:0
untoldwind commented 5 months ago

This should be fixed in pre-release 0.5.8.0 (https://github.com/untoldwind/KontrolSystem2/releases/tag/v0.5.8.0). I was already working on improvements to the REPL system. The command-line is not integrated into the console itself (not entirely finished yet).

versvisa commented 5 months ago

I'm surprised that the outcome is different for REPL vs. normal code.

I just stumbled over this while debugging another issue, which turned out to be my fault.