GeezerVison is showing github.com — Tab completion for block-scoped variables doesn't work in REPL · Issue #983 · nodejs/node
Tab completion for block-scoped variables doesn't work in REPL #983Labels confirmed-bugIssues and PRs for confirmed bugs.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.replIssues and PRs related to the REPL subsystem. DescriptionUsing version 1.4.1 REPL mode, it seems that tab completion for block-scoped variables (i.e. let and const statements) doesn't show suggestions, while tab completion for variables declared with var 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 and const. Reacted by Avindra Goolcharan Activityvkurchatkin commented on Feb 27, 2015 A test (run with --use_strict):
require('assert').equal(require('vm').runInNewContext(`
let a = 42;
this.a
`), 42);
summoning @domenic. benjamingr commented on Feb 27, 2015 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 bazbar
The test @vkurchatkin posted also fails. bnoordhuis commented on Feb 27, 2015 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. var bindings have global scope but let bindings 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. vkurchatkin commented on Feb 27, 2015 the question is, this the correct behaviour according to spec? benjamingr commented on Feb 28, 2015 domenic commented on Mar 1, 2015 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. Fishrock123 commented on Jul 1, 2015 Is this actually an issue then? RB14 commented on Jul 1, 2015 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. jasnell commented on Apr 2, 2016 Appears to be fixed in master. Closing. jgranduel commented on Sep 21, 2017 Hi,
node-8.5.0 REPL win10... seems to still be an issue. Any news?
MetadataMetadataconfirmed-bugIssues and PRs for confirmed bugs.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.replIssues and PRs related to the REPL subsystem. DevelopmentNo branches or pull requestsIssue actions
|