Commit 30c931d
fix(parser): ADR-009 conformance — all 12 valid tests now parse (was 0/12)
Six parser/lexer issues resolved:
1. Float scientific notation crash (`1.0e10` → Failure("float_of_string"))
— sedlex interprets `Opt(a, b, c)` as `Opt(a)` followed by b, c rather
than wrapping the full sequence; fixed by extracting `float_exponent` as a
named sub-regexp so `Opt float_exponent` groups correctly.
2. Type declaration semicolons optional — conformance spec omits trailing `;`
on `type Foo = ...` aliases and inline enum declarations; added `SEMICOLON?`
to both `type_decl` productions.
3. Enum leading-pipe syntax — `type X = | A | B` (spec style) now accepted
alongside `type X = A | B` (classic style); new production with `EQ PIPE`.
4. Effect op type parameters — `fn await[T](promise: Promise[T]) -> T;`
inside effect blocks failed because `effect_op_decl` lacked `type_params?`.
5. Row variable support — two interrelated fixes:
a. Type parameters: `fn get_x[..r](...)` — `type_param` now accepts
`ROW_VAR` (lexed as a single `..r` token, not `DOTDOT lower_ident`).
b. Record types: `{x: Int, ..r}` — replaced `separated_list(COMMA, row_field)
COMMA? row_tail?` with custom `ty_record_body/ty_record_rest` recursive
rules that avoid the LALR(1) greedy-separator conflict.
c. Record expressions: `{ id: id, ..record }` — analogous
`expr_record_body/expr_record_rest` rules; `expr_record_spread` handles
both `ROW_VAR` idents and `DOTDOT expr` forms.
6. Keyword field names — `handle` (a keyword) used as a field name in
`type Resource = own { handle: Int }` and `r.handle` field access.
Introduced `field_name` rule (ident + HANDLE) used in struct_field,
row_field, record_field, pattern_field, and expr_postfix DOT access.
Struct literal expressions (`Point { x: v, y: w }`) also added to
`expr_primary` to support conformance/valid/007_struct_def.affine.
All 12 valid conformance tests: 12/12 parse + output matches expected.
All 68 E2E tests: 0 regressions.
12 invalid conformance tests: 10/12 correctly reject (pre-existing: empty
match accepted, unknown string escapes silently ignored — out of scope).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 1ba5b92 commit 30c931d
14 files changed
Lines changed: 3088 additions & 79 deletions
File tree
- conformance/valid
- lib
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
0 commit comments