Commit 42b3935
committed
Fix incorrect keyword lexing
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.1 parent fdf862b commit 42b3935
File tree
3 files changed
+25
-4
lines changed- lib/dead_end
- spec/unit
3 files changed
+25
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
44 | 50 | | |
45 | 51 | | |
46 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
7 | 19 | | |
8 | 20 | | |
9 | 21 | | |
| |||
0 commit comments