-
Notifications
You must be signed in to change notification settings - Fork 26
Implement proper REPL #515
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, the other workspace members don't use a nested src
directory. I'm not super tied to that, but is there a reason you added it here? The only thing at the top-level looks like Cargo.toml
Ah I see, that's just how |
This comment has been minimized.
This comment has been minimized.
Yea the first error is fixed by my latest commit, but the other error is weird |
You're passing |
This fixes the CI failure in #515 (comment) and is generally good practice.
This fixes the CI failure in #515 (comment) and is generally good practice.
@@ -345,6 +345,44 @@ impl<B: Backend> Compiler<B> { | |||
|
|||
pub type Product = <cranelift_object::ObjectBackend as Backend>::Product; | |||
|
|||
/// Compiles a single declaration. | |||
pub fn compile_decl<B: Backend>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks copy/pasted from https://github.com/jyn514/saltwater/pull/515/files#diff-376fa271c6951618907ff944ff30e93aL368. Rather than duplicating the code, can you change that to call this function instead? That way they're consistent.
match repl.run() { | ||
Ok(_) => {} | ||
Err(err) => { | ||
println!("error: {}", err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, these errors are only sometimes showing up.
>> "a";
error: expression returns unsupported type: Array(Char(true), Fixed(2))
>> @
# I pressed ctrl+c
>> x = 1
>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines only print the error that is returned by rustyline
if something terminal related fails.
The input isn't valid because the Validator
checks if the input is a valid expression (which fails because x
is not declared, I need to fix that).
Imo it's better to remove the "only expressions are valid input" check because it can be really confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but this isn't reporting the error at all, which is a bug. Do you know how to fix that? I'm not sure entirely where the syntax errors are bubbling up - maybe in execute_code
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The errors are reported in process_line
match repl.run() { | ||
Ok(_) => {} | ||
Err(err) => { | ||
println!("error: {}", err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, but this isn't reporting the error at all, which is a bug. Do you know how to fix that? I'm not sure entirely where the syntax errors are bubbling up - maybe in execute_code
?
Should I wait until |
For now let's just add |
Ok(_) => {} | ||
Err(err) => { | ||
// TODO: Proper error reporting | ||
println!("error: {}", err.data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bit doesn't seem to be working (as mentioned above):
>> @
;
# no output
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it's not a valid expression and thus get declined by rustyline.
It's the last pr for a repl, I swear 😅
Resolves #372