Skip to content
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

.load accumulates indentation #47673

Closed
edemaine opened this issue Apr 22, 2023 · 2 comments · Fixed by #49461
Closed

.load accumulates indentation #47673

edemaine opened this issue Apr 22, 2023 · 2 comments · Fixed by #49461
Labels
confirmed-bug Issues with confirmed bugs. repl Issues and PRs related to the REPL subsystem.

Comments

@edemaine
Copy link

Version

v19.9.0

Platform

Microsoft Windows NT 10.0.22621.0 x64

Subsystem

repl

What steps will reproduce the bug?

  1. Create a file example.js with the following contents:
function f() {
  console.log('hello')
  console.log(`goodbye
world
  !`)
}
f()
  1. Run the REPL via node, and enter the following command:
> .load example.js

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

I expect the REPL to repeat code exactly as it appears in example.js:

function f() {
  console.log('hello')
  console.log(`goodbye
world
  !`)
}
f()

And then for the code to output:

hello
goodbye
world
  !

(For example, this is the output from node example.js.)

What do you see instead?

The REPL repeats the code with accumulated indentation, where each line includes all of the indentation from all previous lines:

function f() {
  console.log('hello')
    console.log(`goodbye
    world
      !`)
      }
      f()

This results in incorrect behavior with the template string. The code outputs:

hello
goodbye
    world
      !

Additional information

This issue arose when using the repl package to make a REPL for an indentation-based language, Civet. .load is then nonfunctional; see DanielXMoore/Civet#509

But it also affects correctness of JavaScript as illustrated above.

@VoltrexKeyva VoltrexKeyva added the repl Issues and PRs related to the REPL subsystem. label Apr 22, 2023
@kvakil kvakil added the confirmed-bug Issues with confirmed bugs. label May 12, 2023
@GethosTheWalrus
Copy link

GethosTheWalrus commented Jun 16, 2023

I'll take a stab at this one. Open to hearing any ideas anyone may have before I dig in.

@Prateek462003
Copy link

hi @GethosTheWalrus If ur not working on it right now can i look into this issue

STRd6 added a commit to STRd6/node that referenced this issue Sep 2, 2023
STRd6 added a commit to STRd6/node that referenced this issue Sep 2, 2023
When using .load the REPL would accumulate indentation with each line
including the indentation from all previous lines. Now it keeps the
indentation at the correct level.

Fixes: nodejs#47673
STRd6 added a commit to STRd6/node that referenced this issue Sep 7, 2023
When using .load the REPL would accumulate indentation with each line
including the indentation from all previous lines. Now it keeps the
indentation at the correct level.

Fixes: nodejs#47673
nodejs-github-bot pushed a commit that referenced this issue Sep 21, 2023
When using .load the REPL would accumulate indentation with each line
including the indentation from all previous lines. Now it keeps the
indentation at the correct level.

Fixes: #47673
PR-URL: #49461
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
ruyadorno pushed a commit that referenced this issue Sep 28, 2023
When using .load the REPL would accumulate indentation with each line
including the indentation from all previous lines. Now it keeps the
indentation at the correct level.

Fixes: #47673
PR-URL: #49461
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
alexfernandez pushed a commit to alexfernandez/node that referenced this issue Nov 1, 2023
When using .load the REPL would accumulate indentation with each line
including the indentation from all previous lines. Now it keeps the
indentation at the correct level.

Fixes: nodejs#47673
PR-URL: nodejs#49461
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants