Repository navigation
Tab completion for block-scoped variables doesn't work in REPL #983
Description
Activity
- addedreplIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.
on Feb 27, 2015 A test (run with
--use_strict):require('assert').equal(require('vm').runInNewContext(` let a = 42; this.a `), 42);
summoning @domenic.
I can reproduce this on v1.4.1 on OSX.
$ ./iojs --use_strict
let foobar = 40;
var bazbar = 100;
foo // hit tab, no autocomplete
baz // hit tab, autocompletes to bazbarThe 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.
varbindings have global scope butletbindings don't, i.e.:> var x = 1; typeof global['x'] // 'number' > let y = 1; typeof global['y'] // 'undefined'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
var(or should I say old-style) variables, and not for the new kinds of declarations.
Since auto-complete is a feature of io.js (and node.js), and it's a very useful feature if you ask me, I think this behavior should be fixed (if possible of course).. so I think it should still be considered as an issue.- addedhelp wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.confirmed-bugIssues and PRs for confirmed bugs.Issues and PRs for confirmed bugs.
on Mar 11, 2016 Appears to be fixed in master. Closing.
23 remaining items
Hi,
node-8.5.0 REPL win10... seems to still be an issue. Any news?- added a commit that references this issue
on Jul 27, 2026
Using version 1.4.1 REPL mode, it seems that tab completion for block-scoped variables (i.e.
letandconststatements) doesn't show suggestions, while tab completion for variables declared withvaror 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
letandconst.