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

Let statement on compiler repl gives out a value and not null #6

Open
Yag000 opened this issue Aug 3, 2023 · 1 comment
Open

Let statement on compiler repl gives out a value and not null #6

Yag000 opened this issue Aug 3, 2023 · 1 comment
Labels
bug Something isn't working compiler Issues about the compiler itself good first issue Good for newcomers repl REPL related issues

Comments

@Yag000
Copy link
Owner

Yag000 commented Aug 3, 2023

Description

When using the compiler on the REPL, I get a value different from null when assigning variables with a let statement."

Steps to reproduce

cargo run

and simply type

let a = 4;

Expected behavior

Welcome to the Monkey programming language! Compiler and Interpreter by @Yag000, in Rust
Feel free to type in commands

>> let a = 4;

Actual behavior

Welcome to the Monkey programming language! Compiler and Interpreter by @Yag000, in Rust
Feel free to type in commands

>> let a = 4;
4

Additional information

This only happens when using the compiler as an engine. This is due to the fact that 4 is at the top of the stack, which is not an intended behavior in this case. NULL should be there. I will look at this later as it does not have any practical implications, and it will not mess with anyone, but it should be addressed.

@Yag000 Yag000 added bug Something isn't working compiler Issues about the compiler itself repl REPL related issues labels Aug 3, 2023
@Yag000 Yag000 changed the title [Bug] Let statement on compiler repl give aout a value and not null Aug 3, 2023
@Yag000 Yag000 changed the title Let statement on compiler repl give aout a value and not null Let statement on compiler repl give out a value and not null Aug 3, 2023
@Yag000 Yag000 changed the title Let statement on compiler repl give out a value and not null Let statement on compiler repl gives out a value and not null Aug 8, 2023
@Yag000
Copy link
Owner Author

Yag000 commented Aug 10, 2023

I would argue that this is just a feature of the compiler, since when using the REPL you just get the top constant, which in most cases is, ans should be, a value different from 'NULL'. To solve this I would hard code on the REPL itself that it should only print a value if the last input was an expression statement, and ignore the top value in any other case.

@Yag000 Yag000 added the good first issue Good for newcomers label Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler Issues about the compiler itself good first issue Good for newcomers repl REPL related issues
Projects
None yet
Development

No branches or pull requests

1 participant