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

[repl] Errors use bad code format #210

Closed
Brayan-724 opened this issue Oct 23, 2024 · 3 comments · Fixed by #214
Closed

[repl] Errors use bad code format #210

Brayan-724 opened this issue Oct 23, 2024 · 3 comments · Fixed by #214
Assignees
Labels
bug Something isn't working diagnostics related to outputting code errors

Comments

@Brayan-724
Copy link
Contributor

Using ezno from npm with deno.

image

❯ nix run nixpkgs#deno -- run -A npm:ezno repl
Entering REPL. Exit with `close()`
> // Unused code
> const x: 5 = 4 + 2;
error: 
  ┌─ CLI.tsx:1:14
  │
1 │ // Unused codeconst x: 5 = 4 + 2;
  │          -   ^^^^^ Type 6 is not assignable to type 5
  │          │    
  │          Variable declared with type 5

It appears to don't save new lines properly, exploring a few I found that repl source code append happens here and I think it could be fixed easy

@kaleidawave kaleidawave added bug Something isn't working diagnostics related to outputting code errors labels Oct 23, 2024
@kaleidawave kaleidawave self-assigned this Oct 23, 2024
@kaleidawave
Copy link
Owner

Interesting! Yes the REPL maintains a single file and appends entries to it. Haven't worked on the REPL in ages. I should check

  1. That there is a new line character between entries
  2. The "appended" AST has positions offset by the current source length

Will have a look at those two when I have the time. Maybe to do in #209

I wonder if there a way to add a test this? Need to spawn a REPL instance, pass some information over stdin and expect the stdout


1 │ // Unused codeconst x: 5 = 4 + 2;
  │          -   ^^^^^ Type 6 is not assignable to type 5
  │          │    
  │          Variable declared with type 5

is being confused as

1 │ const x: 5 = 4 + 2;
  │          -   ^^^^^ Type 6 is not assignable to type 5
  │          │    
  │          Variable declared with type 5

@kaleidawave
Copy link
Owner

Had a look and I think I can figure out a fix. I am also going to try and fix the other CLI JS problems #204 and #205 at the same time.

First I want to add a test. Moving the single file to use the new NodeJS testing framework. Also want to test the repl interaction. I don't know if @Brayan-724 you know about nodejs spawning a process, sending stdin, reading stdout. I am trying this but it hangs? 925cec9 (#209)

@kaleidawave kaleidawave linked a pull request Nov 10, 2024 that will close this issue
@kaleidawave
Copy link
Owner

This should be fixed in the latest release. Added some .strip calls to remove trailing new lines and stuff

image

I think there is currently a parser bug with new lines that you may encounter. Other than that I have got it working now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working diagnostics related to outputting code errors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants