visitor-as icon indicating copy to clipboard operation
visitor-as copied to clipboard

Fix parsing of import statement

Open mattjohnsonpint opened this issue 1 year ago • 1 comments
trafficstars

Parsing a top-level import statement should work, but fails with the following:

AssertionError: assertion failed
      at Y.assert (file:///Users/matt/Code/visitor-as/node_modules/assemblyscript/dist/assemblyscript.js:9:3029)
      at Kn.parseImport (file:///Users/matt/Code/visitor-as/node_modules/assemblyscript/dist/assemblyscript.js:17:124365)
      at Kn.parseTopLevelStatement (file:///Users/matt/Code/visitor-as/node_modules/assemblyscript/dist/assemblyscript.js:17:102113)
      at SimpleParser.parseTopLevelStatement (file:///Users/matt/Code/visitor-as/dist/simpleParser.js:24:33)
      at Context.<anonymous> (file:///Users/matt/Code/visitor-as/__tests__/tests.spec.js:166:20)
      at process.processImmediate (node:internal/timers:478:21)

This PR adds a test for that, and fixes it by setting the parser's currentSource property.

I'm not certain if the same fix is required for the other parsing methods or not. I only found the problem while trying to parse an import statement. LMK if you want me to make the same fix to the other parsing methods. Thanks.

mattjohnsonpint avatar Feb 22 '24 17:02 mattjohnsonpint

Looks like @jtenner has been away from GitHub for some time now. No worries. I have a workaround. I just didn't want to this to get lost, for whenever he returns.

mattjohnsonpint avatar Feb 22 '24 19:02 mattjohnsonpint