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

Better error message for invalid octal digit #15903

Closed
jruderman opened this issue Jul 22, 2014 · 5 comments
Closed

Better error message for invalid octal digit #15903

jruderman opened this issue Jul 22, 2014 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST

Comments

@jruderman
Copy link
Contributor

fn main() {
    0o19;
}

Gives me:

error: expected one of `;`, `}` but found `9`

It would be better to say something like:

error: `9` is not a valid octal digit
@SiegeLord
Copy link
Contributor

Fixing this will break some (arguably dodgy) code:

#![feature(macro_rules)]

macro_rules! test
{
    ($a: expr $b: expr) =>
    {
        $a as u32 + $b as u32
    }
}

fn main()
{
    println!("{}", test!(0o19));
}

@lilyball
Copy link
Contributor

@SiegeLord Egad, that code deserves to be broken.

@steveklabnik steveklabnik added A-parser Area: The parsing of Rust source code to an AST A-diagnostics Area: Messages for errors, warnings, and lints labels Jan 24, 2015
@steveklabnik
Copy link
Member

Same error today.

@bombless
Copy link
Contributor

I think this has been fixed by #23872
The example code give us error: invalid digit for a base 8 literal for Beta.

@fhahn
Copy link
Contributor

fhahn commented Oct 9, 2015

It is indeed fixed in master and there is also a testcase src/test/parse-fail/lex-bad-octal-literal.rs, so I think this issue can be closed.

@sfackler sfackler closed this as completed Oct 9, 2015
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 16, 2023
Fix builtin line! expansion

`concat` expects only literals, not whole syntax nodes, so we need to expand as such
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-parser Area: The parsing of Rust source code to an AST
Projects
None yet
Development

No branches or pull requests

8 participants
@lilyball @steveklabnik @fhahn @SiegeLord @jruderman @bombless @sfackler and others