…and the script prints 42 to the output afterwards.
Hence, it seems that the error recovery setting of the ANTLR lexer/parser only prints error to stderr without raising any errors in the Java code.
I’m not sure if MTS sets the error recovery manually. Let’s dive into the code.
Issue is caused by the Mts3Lexer instance only having its default error listener (which prints any errors to stderr and continues as if nothing happened). By adding a custom error handler which functions similarly to the existing MtsAntlrErrorListener class, this issue can be prevented.