GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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 #983

New issue
Copy link
New issue
Copy link
Closed
Closed
Tab completion for block-scoped variables doesn't work in REPL#983
Copy link
Assignees
fhinkelFishrock123
Labels
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.

Description

@RB14
RB14
opened on Feb 27, 2015
Issue body actions

Using 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

Activity

Next
  1. micnic
    added
    replIssues and PRs related to the REPL subsystem.
    on Feb 27, 2015
  2. vkurchatkin commented on Feb 27, 2015

    @vkurchatkin
    vkurchatkin
    on Feb 27, 2015
    Contributor
    More actions

    A test (run with --use_strict):

    require('assert').equal(require('vm').runInNewContext(`
      let a = 42;
      this.a
    `), 42);

    summoning @domenic.

  3. benjamingr commented on Feb 27, 2015

    @benjamingr
    benjamingr
    on Feb 27, 2015
    Member
    More actions

    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.

  4. bnoordhuis commented on Feb 27, 2015

    @bnoordhuis
    bnoordhuis
    on Feb 27, 2015
    Member
    More actions

    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.

  5. vkurchatkin commented on Feb 27, 2015

    @vkurchatkin
    vkurchatkin
    on Feb 27, 2015
    Contributor
    More actions

    the question is, this the correct behaviour according to spec?

  6. RB14
    closed this as completedon Feb 27, 2015
  7. RB14
    reopened this on Feb 27, 2015
  8. benjamingr commented on Feb 28, 2015

    @benjamingr
    benjamingr
    on Feb 28, 2015
    Member
    More actions

    @vkurchatkin it appears that it is.

  9. domenic commented on Mar 1, 2015

    @domenic
    domenic
    on Mar 1, 2015
    Contributor
    More actions

    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.

  10. Fishrock123 commented on Jul 1, 2015

    @Fishrock123
    Fishrock123
    on Jul 1, 2015
    Contributor
    More actions

    Is this actually an issue then?

  11. RB14 commented on Jul 1, 2015

    @RB14
    RB14
    on Jul 1, 2015
    Author
    More actions

    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.

  12. Trott
    added
    help wantedIssues that need assistance from volunteers or PRs that need help to proceed.
    confirmed-bugIssues and PRs for confirmed bugs.
    on Mar 11, 2016
  13. jasnell commented on Apr 2, 2016

    @jasnell
    jasnell
    on Apr 2, 2016
    Member
    More actions

    Appears to be fixed in master. Closing.

  14. jasnell
    closed this as completedon Apr 2, 2016
  15. 23 remaining items

  16. jgranduel commented on Sep 21, 2017

    @jgranduel
    jgranduel
    on Sep 21, 2017
    More actions

    Hi,
    node-8.5.0 REPL win10... seems to still be an issue. Any news?

  17. targos
    closed this as completedin 416c0econ Dec 21, 2017
  18. MylesBorins
    added 4 commits that reference this issue on Jan 8, 2018

    repl: show lexically scoped vars in tab completion

    56bfbc2

    repl: show lexically scoped vars in tab completion

    ab39f6e

    repl: show lexically scoped vars in tab completion

    30273d4

    repl: show lexically scoped vars in tab completion

    3831d87
  19. sjarmak
    added a commit that references this issue on Jul 27, 2026

    repl: show lexically scoped vars in tab completion

    416c0ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @Fishrock123
    Fishrock123
  • @fhinkel
    fhinkel

Labels

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.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.