-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Tab completion for block-scoped variables doesn't work in REPL #983
Comments
A test (run with require('assert').equal(require('vm').runInNewContext(`
let a = 42;
this.a
`), 42); summoning @domenic. |
I can reproduce this on v1.4.1 on OSX.
The test @vkurchatkin posted also fails. |
I think this can be explained because of how the REPL does autocompletion: it spawns a nested VM context that contains a copy of the globals from the parent context.
I can't think of a good fix off the top of my head. |
the question is, this the correct behaviour according to spec? |
@vkurchatkin it appears that it is. |
Right, indeed, let and const and class don't add to the global object, but instead to a separate scope contour. Unsure how to deal with this given the implementation details @bnoordhuis mentions. |
Is this actually an issue then? |
Well, as the one who opened this ticket, I still find it odd that auto-complete in REPL would work for only |
Appears to be fixed in master. Closing. |
Is this actually closed? Tab completion of |
neither is it for me. I'm on node v6.2.0 |
I'll reopen, it doesn't work with master either. |
Can confirm that tab completion isn't working for |
Anyone know if there is a way to hook into what variables are in the current scope? VM hacks count. Would running in/hooking into a new |
@nodejs/v8? |
You can through the debugger API but you have to fake a breakpoint. Interestingly though, tab completion for let and const bindings seems to work with master. |
It doesn't seem to work for me. What did you try ? |
Just confirmed this still doesn't work on |
cc @fhinkel |
I'll check what the debugger does, since it works there. If that doesn't work for us, here's a workaround we might try: Since vm intercepts all variable declarations anyways (and REPL sends everything through vm), we could also store the variable names in a list, and then do tab completion using that list. /cc @AnnaMag |
ping @fhinkel did you get anywhere here? |
Sorry, didn't get too much time on this yet. |
ping @fhinkel, were you ever able to look into this? :D |
Help us @fhinkel, you're our only hope! |
This appears to no longer be an issue. |
@jasnell I think it's still an issue. Note that Chrome devtools are also unable to provide completion for |
hmm.... yep, quick verification test shows that I was testing the wrong thing. Thanks for reopening @targos |
Hi, |
Use the V8 inspector protocol, if available, to query the list of lexically scoped variables (defined with `let`, `const` or `class`). PR-URL: nodejs#16591 Fixes: nodejs#983 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Using version 1.4.1 REPL mode, it seems that tab completion for block-scoped variables (i.e.
let
andconst
statements) doesn't show suggestions, while tab completion for variables declared withvar
or otherwise just assigned a value without a deceleration, does show up a list of suggestions.Of course, this happens in strict mode, or else I couldn't use
let
andconst
.The text was updated successfully, but these errors were encountered: