+
Skip to content

negating bool crashes parser #938

Open
@mgood

Description

@mgood

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)}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载