Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

negating bool crashes parser #938

Open
mgood opened this issue Mar 3, 2025 · 0 comments
Open

negating bool crashes parser #938

mgood opened this issue Mar 3, 2025 · 0 comments

Comments

@mgood
Copy link

mgood commented Mar 3, 2025

I was writing some test cases for my Go Ink runtime engine, and testing some scenarios with numeric type coercions.

I noticed most unsupported operations produce an error like:

RUNTIME ERROR: (0.183): Cannot perform operation '-' on String

However, trying to negate a boolean literal results in a stack trace in the parser itself:

{-true}
Unhandled exception. System.Exception: Unexpected operation or number type
   at Ink.Parsed.UnaryExpression.WithInner(Expression inner, String op)
   at Ink.InkParser.ExpressionUnary()
   at Ink.InkParser.Expression(Int32 minimumPrecedence)
   at Ink.InkParser.Expression()
   at Ink.StringParser.Parse[T](SpecificParseRule`1 rule)
   at Ink.InkParser.ConditionExpression()
   at Ink.InkParser.InnerLogic()
   at Ink.StringParser.ParseObject(ParseRule rule)
   at Ink.StringParser.Expect(ParseRule rule, String message, ParseRule recoveryRule)
   at Ink.InkParser.InlineLogic()
   at Ink.StringParser.ParseObject(ParseRule rule)
   at Ink.StringParser.OneOf(ParseRule[] array)
   at Ink.InkParser.InlineLogicOrGlueOrStartTag()
   at Ink.StringParser.ParseObject(ParseRule rule)
   at Ink.StringParser.<>c__DisplayClass58_0.<Optional>b__0()
   at Ink.StringParser.ParseObject(ParseRule rule)
   at Ink.StringParser.Interleave[T](ParseRule ruleA, ParseRule ruleB, ParseRule untilTerminator, Boolean flatten)
   at Ink.InkParser.MixedTextAndLogic()
   at Ink.StringParser.Parse[T](SpecificParseRule`1 rule)
   at Ink.InkParser.LineOfMixedTextAndLogic()
   at Ink.StringParser.ParseObject(ParseRule rule)
   at Ink.StringParser.OneOf(ParseRule[] array)
   at Ink.InkParser.StatementAtLevel(StatementLevel level)
   at Ink.InkParser.<>c__DisplayClass145_0.<StatementsAtLevel>b__0()
   at Ink.StringParser.ParseObject(ParseRule rule)
   at Ink.StringParser.Interleave[T](ParseRule ruleA, ParseRule ruleB, ParseRule untilTerminator, Boolean flatten)
   at Ink.InkParser.StatementsAtLevel(StatementLevel level)
   at Ink.InkParser.Parse()
   at Ink.Compiler.Parse()
   at Ink.Compiler.Compile()
   at Ink.CommandLineTool..ctor(String[] args)
   at Ink.CommandLineTool.Main(String[] args)
Abort trap: 6

This seems unlikely to serve a practical purpose in a real story, but wanted to document it since this results in a big stack trace in the Inky UI if you write it there, and negating boolean values at runtime seems to be supported, e.g.:

{-(2 == 2)}
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

No branches or pull requests

1 participant