-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support relative import #1050
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
Support relative import #1050
Conversation
I'm not sure why WASM's not passing; I restarted the build and im hoping it was just a fluke. |
When I run the test locally it passes. |
It is not a fluke for sure... |
@@ -912,7 +912,9 @@ impl Frame { | |||
.iter() | |||
.map(|symbol| vm.ctx.new_str(symbol.to_string())) | |||
.collect(); | |||
let module = vm.import(module, &vm.ctx.new_tuple(from_list))?; | |||
let level = module.chars().take_while(|char| *char == '.').count(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of splitting of the level here, it's better to modify the parser to be able to handle this such that have AST nodes with a level inside. This way, the level is already known at parse time, and is passed in as a second argument. See also: https://greentreesnakes.readthedocs.io/en/latest/nodes.html#imports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a big change tough, so it can be done in a follow up pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I will do that in a different PR.
I am not very familiar with javascript... The only thing I get in the error message is |
Debugging travis can be a pain. Is the issue not present on the master branch? |
Did you try to reproduce the scenario locally? |
Try rebasing to master, #1039 added an import function specifically for wasm that might fix the issue. |
It passes and everything look good on the demo on locally.
Already did... I hoped it will be resolved by that as well. I will try removing stuff from the change to pinpoint the problem with the WASM. |
The problematic line is the copy of the local variables as parameter of |
That's so strange, because as far as I can tell based on the tests that |
vm/src/vm.rs
Outdated
@@ -314,7 +314,7 @@ impl VirtualMachine { | |||
func, | |||
vec![ | |||
self.ctx.new_str(module.to_string()), | |||
self.get_locals().clone().as_object().clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once you do re-add this, it can just be self.get_locals().into_object()
Aha! In the demo page, you can look at the global variable
Which is from here in pub fn current_scope(&self) -> Ref<Scope> {
let frame = self
.current_frame()
.expect("called current_scope but no frames on the stack");
Ref::map(frame, |f| &f.scope)
} Not sure exactly what to do about this, but that's the root of the problem. Odd. Does |
Thanks @coolreader18. Are you seeing this when running locally or on travis? How can I get |
@coolreader18 can you share the full stacktrace please? |
My guess is this: let result = vm.run_code_obj(code, scope.borrow().clone());
convert::pyresult_to_jsresult(vm, result) When we run the code in the line before we acutally push a frame to the |
Hallelujah! Do you want to merge this now? |
Very very very much 😃 |
Can we improve on error reporting so that we might be able to pinpoint these issues easier in the future? |
That's probably doable, I'll look into it. |
Should solve #55.