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

Properly reject octal number literals #330

Merged
merged 1 commit into from
Mar 23, 2021

Conversation

Y-Nak
Copy link
Member

@Y-Nak Y-Nak commented Mar 23, 2021

What was wrong?

Currently, the analyzer doesn't consider number literals that start with 0. This leads to ICE in the yul mapping pass.
fixes #222

How was it fixed?

Reject a number literal if it starts with 0 and has more than two digits.

To-Do

  • OPTIONAL: Update Spec if applicable
  • Add entry to the release notes (may forgo for trivial changes)
  • Clean up commit history

Related problem

I also found that lexer doesn't tokenize correctly if number literals start with 0 followed by non zero value.
For example, 02 is tokenized into

    [
        Token {
            typ: NUMBER,
            string: "0",
            span: Span {
                start: 0,
                end: 1,
            },
            line: "02\n",
        },
        Token {
            typ: NUMBER,
            string: "2",
            span: Span {
                start: 1,
                end: 2,
            },
            line: "02\n",
        },
        Token {
            typ: NEWLINE,
            string: "\n",
            span: Span {
                start: 2,
                end: 3,
            },
            line: "02\n",
        },
        Token {
            typ: ENDMARKER,
            string: "",
            span: Span {
                start: 3,
                end: 3,
            },
            line: "",
        },
    ],

I'll open an issue for this and address it in another PR.

EDIT: opened #331.

Copy link
Member

@g-r-a-n-t g-r-a-n-t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Thanks for the contribution 🦀

@g-r-a-n-t g-r-a-n-t merged commit ee9ee3c into ethereum:master Mar 23, 2021
@Y-Nak Y-Nak deleted the reject-octal-number branch March 24, 2021 02:57
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

Successfully merging this pull request may close these issues.

Yul compilation failed: Illegal token: Octal numbers not allowed.
2 participants