-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cyclic import/export segfault #568
Conversation
Is throwing an exception the best approach here? The examples works in both node and deno (with extensions .mjs and ./ path in the import) |
This is quite complicated. Node, deno, bun etc all handle the case in the issue. However they do not handle this case: //index.js
import { a } from "./a.js";
console.log(a);
//a.js
import { b } from "./b.js";
export const a = "aloha";
console.log("from a", b);
//b.js
import { a } from "./a.js";
export const b = "bye";
console.log("from b", a); The difference is when we export an object it should work as we can return the same reference, from b which later get's initialized in a as per Node.js documentation:
More info on this behavior is found here |
The Node docs are not relevant here, what does the ES spec say? |
It's a bit hard to decipher but this seems relevant: Also the issue use case also works in all major browsers |
Thanks for the link! Still a bit confusing since your example and the original behave different but seem the same on the surface. Hum, certainly throwing an error is a better solution than to crash, so there is that. I haven't touched the import code much, so I'm not sure right off the bat how hard it would be to make this work the way the other platforms do. It's also somewhat surprising test262 doesn't catch this :-/ |
After lots of yak shaving to enable negative tests... I'm going to land this first in order to fix the segfault (because SyntaxError > segfault) and then implement the proper behavior at some later time, because that's going to be a more elaborate change. |
ffs, the windows buildbots still trip up on output from tests... The netbsd failure is this;
Which is a flake. Also happened regularly on cygwin, see #184. |
Argh.... fixing up the line endings by stubbing out the \r breaks some of the test262 tests. Okay, back to the drawing board. |
Before this commit it segfaulted, now it throws a SyntaxError. That's still not correct behavior but better than segfaulting. To be continued. Refs: quickjs-ng#567
netbsd again... "VM is booting" for the last 13 minutes and counting. Everyting else is green though! |
Consider the following two files:
And:
Before this commit, it crashed with a nullptr dereference. Throw a "circular reference when looking for export" SyntaxError.
No test because the test suite currently isn't equipped for tests that throw exceptions at import time.
Fixes: #567