Skip to content

Fix parsing of import statement#45

Open
mattjohnsonpint wants to merge 1 commit into
as-pect:masterfrom
mattjohnsonpint:fix-import
Open

Fix parsing of import statement#45
mattjohnsonpint wants to merge 1 commit into
as-pect:masterfrom
mattjohnsonpint:fix-import

Conversation

@mattjohnsonpint
Copy link
Copy Markdown

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.

Copy link
Copy Markdown
Collaborator

@willemneal willemneal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me! Thanks! @jtenner Are you still maintaining this?

@mattjohnsonpint
Copy link
Copy Markdown
Author

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.

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

Successfully merging this pull request may close these issues.

2 participants