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

Out: IRust: Are you missing a ; ? #62

Closed
ulidtko opened this issue Dec 3, 2019 · 7 comments
Closed

Out: IRust: Are you missing a ; ? #62

ulidtko opened this issue Dec 3, 2019 · 7 comments

Comments

@ulidtko
Copy link

ulidtko commented Dec 3, 2019

Hi!

This rather simple code compiles just fine with rustc:

fn parse_troop_power(troops: &str) -> u32 {
    troops.split(' ')
          .map(|w| w.parse::<u32>().expect("input format"))
          .fold(0, |s, x| s + x)
}

But when pasted into IRust, gives weird error:

Screenshot from 2019-12-04 00-28-55

Curiously, :load from a scratch-file works just fine, too. But it's the whole point of a REPL — to not have to use scratch files right?..

@ulidtko
Copy link
Author

ulidtko commented Dec 3, 2019

irust --version → 0.7.30, FWIW

@sigmaSd
Copy link
Owner

sigmaSd commented Dec 4, 2019

Hi welcome! As IRust suggest you have to add ';' at the end of the function definition
fn a() {}; instead of fn a() {}

@sigmaSd
Copy link
Owner

sigmaSd commented Dec 4, 2019

This issue reoccurs I guess I have to add a FAQ in the readme ^^

@smolck
Copy link
Contributor

smolck commented Dec 4, 2019

@sigmaSd The error given by IRust in this case isn’t very helpful IMO because it doesn’t say anything about where the semicolon should go. Most people will probably expect (from other REPLs, like IPython) functions to not require semicolons at the end, and so won’t think to put a semicolon after the function definition. Is there any way we can remove that requirement? Or at least improve the error message?

@sigmaSd
Copy link
Owner

sigmaSd commented Dec 4, 2019

Hi @smolck ! I think you're right since by now I saw this issue come up a lot of times, maybe we can just special case functions structs and traits maybe?

Here is an initial test 60e541c, 18b78d0 would be great if you test it and report back, I just want to be sure of two things: 1- does it feel now like you expect 2- does it break other things

@sigmaSd
Copy link
Owner

sigmaSd commented Dec 6, 2019

I found no problem while testing it 195cbec, I think this should be resolved now

@ulidtko
Copy link
Author

ulidtko commented Dec 19, 2019

Yea, looks good to me. Closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants