Skip to content

Conversation

@schneems
Copy link
Collaborator

@schneems schneems commented Jan 4, 2022

For some weird reason this line is detected as a keyword line:

            type: :module,

Though it clearly isn't. Ripper:

require 'ripper'

pp Ripper.lex(<<~'EOM')
  {
    type: :module,
  }
EOM

Produces:

[[[1, 0], :on_lbrace, "{", BEG|LABEL],
 [[1, 1], :on_ignored_nl, "\n", BEG|LABEL],
 [[2, 0], :on_sp, "  ", BEG|LABEL],
 [[2, 2], :on_label, "type:", ARG|LABELED],
 [[2, 7], :on_sp, " ", ARG|LABELED],
 [[2, 8], :on_symbeg, ":", FNAME],
 [[2, 9], :on_kw, "module", ENDFN],
 [[2, 15], :on_comma, ",", BEG|LABEL],
 [[2, 16], :on_ignored_nl, "\n", BEG|LABEL],
 [[3, 0], :on_rbrace, "}", END],
 [[3, 1], :on_nl, "\n", BEG],
 [[4, 0], :on_const, "EOM", CMDARG]]

This is the problem line:

 [[2, 9], :on_kw, "module", ENDFN],

Digging into the IRB source code they handled this case here ruby/ruby@776759e. Based on the description I believe this may be a bug in the lexer, but I'm not sure how to validate it.

@schneems schneems force-pushed the schneems/keyword-wat-fix branch from 42b3935 to 6cc8bb0 Compare January 4, 2022 21:42
For some weird reason this line is detected as a keyword line:

```
            type: :module,
```

Though it clearly isn't. Ripper:

```
require 'ripper'

pp Ripper.lex(<<~'EOM')
  {
    type: :module,
  }
EOM
```

Produces:

```
[[[1, 0], :on_lbrace, "{", BEG|LABEL],
 [[1, 1], :on_ignored_nl, "\n", BEG|LABEL],
 [[2, 0], :on_sp, "  ", BEG|LABEL],
 [[2, 2], :on_label, "type:", ARG|LABELED],
 [[2, 7], :on_sp, " ", ARG|LABELED],
 [[2, 8], :on_symbeg, ":", FNAME],
 [[2, 9], :on_kw, "module", ENDFN],
 [[2, 15], :on_comma, ",", BEG|LABEL],
 [[2, 16], :on_ignored_nl, "\n", BEG|LABEL],
 [[3, 0], :on_rbrace, "}", END],
 [[3, 1], :on_nl, "\n", BEG],
 [[4, 0], :on_const, "EOM", CMDARG]]
```

This is the problem line:

```
 [[2, 9], :on_kw, "module", ENDFN],
```

Digging into the IRB source code they handled this case here ruby/ruby@776759e. Based on the description I believe this may be a bug in the lexer, but I'm not sure how to validate it.
@schneems schneems force-pushed the schneems/keyword-wat-fix branch from 6cc8bb0 to b8c6215 Compare January 4, 2022 21:43
@schneems schneems marked this pull request as ready for review January 4, 2022 22:30
@schneems schneems merged commit 10232e4 into main Jan 4, 2022
@schneems schneems deleted the schneems/keyword-wat-fix branch January 4, 2022 22:30
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.

2 participants