diff options
-rwxr-xr-x | scripts/gen-s-parser.py | 2 | ||||
-rw-r--r-- | src/gen-s-parser.inc | 2 | ||||
-rw-r--r-- | test/unit/test_parsing_error.py | 18 |
3 files changed, 20 insertions, 2 deletions
diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py index 5e5ec494f..8329ae13b 100755 --- a/scripts/gen-s-parser.py +++ b/scripts/gen-s-parser.py @@ -528,7 +528,7 @@ def instruction_parser(): emit(trie) printer.print_line("parse_error:") with printer.indent(): - printer.print_line("throw ParseException(std::string(op));") + printer.print_line("throw ParseException(std::string(op), s.line, s.col);") def print_header(): diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc index 65a780b8b..2fd554107 100644 --- a/src/gen-s-parser.inc +++ b/src/gen-s-parser.inc @@ -2250,7 +2250,7 @@ switch (op[0]) { default: goto parse_error; } parse_error: - throw ParseException(std::string(op)); + throw ParseException(std::string(op), s.line, s.col); #endif // INSTRUCTION_PARSER // clang-format on diff --git a/test/unit/test_parsing_error.py b/test/unit/test_parsing_error.py new file mode 100644 index 000000000..93aab1d16 --- /dev/null +++ b/test/unit/test_parsing_error.py @@ -0,0 +1,18 @@ +from scripts.test.shared import WASM_OPT, run_process +from utils import BinaryenTestCase +import os + + +class ParsingErrorTest(BinaryenTestCase): + def test_parsing_error_msg(self): + module = ''' + (module + (func $foo + (abc) + ) + ) + ''' + p = run_process(WASM_OPT + ['--print', '-o', os.devnull], input=module, + check=False, capture_output=True) + self.assertNotEqual(p.returncode, 0) + self.assertIn("parse exception: abc (at 4:6)", p.stderr) |