Commit 5c377b9
[1.13] Type-check put, return and require -- and give literals a type
Reid ruled these three in, corpus cost accepted.
`put` and `return` already compared types, but only when BOTH sides resolved to a
NAMED type: `valueType` yields None for a predefined one, so exactly the case a
generator trips over was skipped in silence. The named comparison is KEPT -- it is the
stricter rule and the right one where it applies, since RIDDL treats a declared alias
as a distinct name rather than a transparent synonym -- and the TypeExpression check
runs only where the named one could not, so the two cannot double-report.
`require … with` was never type-checked at all: only presence, plus a prompt
ascription. It is checked in `checkStatementScopes` rather than `validateStatement`
because `valueTypeExpr` needs the in-scope lets and foreach elements, which only that
walk carries.
**The real find was that LITERALS had no type**, which I hit by instrumenting the
require check and watching `valueTypeExpr` answer None for `"a string"`. That was not
a gap in these three positions -- it was a gap in the shared helper, so every position
built on it, constructor arguments included, silently skipped its most common argument
shape. Literals are typed now; a NumericLiteral deliberately still is not, because
`checkNumericLiteralConformance` already judges those with a better message.
It found nine genuine type errors in our OWN fixtures -- a string into an Integer
field in six suites, a string where a record or an entity reference was wanted in two
more. Every one is fixed as a fixture defect, not worked around.
One test asserted SILENCE for a string literal on the stated grounds that "a literal
has no resolvable type expression here". That premise is now false, so the case now
asserts the opposite and a NEW case covers the still-valid rule using a value that is
genuinely undeterminable.
Also corrects two mislabelled rule ids that this made visible. `checkAssignable`'s
GENERIC arm -- any assignability failure -- carried `stmt-id-entity-mismatch`, telling
an author their plain type error was a problem with entity identity. It is
`value-type-mismatch` now, and the wrong-entity arm takes the name that describes it.
`stmt-id-type-mismatch` is left with no producer and is RETIRED rather than deleted:
it shipped in rc.25, so its code stays reserved and can never come back meaning
something else.
Corpus cost is two models, both true positives: reactive-bbq returns a String where an
aggregate is declared, ToDoodles puts one where a record is. Tasks filed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent b05c541 commit 5c377b9
15 files changed
Lines changed: 252 additions & 32 deletions
File tree
- language
- input
- src/main/scala/com/ossuminc/riddl/language
- passes/src
- main/scala/com/ossuminc/riddl/passes/validate
- test
- scala-jvm-native/com/ossuminc/riddl/passes/validate
- scala/com/ossuminc/riddl/passes/validate
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1026 | 1026 | | |
1027 | 1027 | | |
1028 | 1028 | | |
1029 | | - | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
1030 | 1033 | | |
1031 | 1034 | | |
1032 | 1035 | | |
| |||
1036 | 1039 | | |
1037 | 1040 | | |
1038 | 1041 | | |
1039 | | - | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
1040 | 1046 | | |
1041 | 1047 | | |
1042 | 1048 | | |
| |||
1048 | 1054 | | |
1049 | 1055 | | |
1050 | 1056 | | |
1051 | | - | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
1052 | 1061 | | |
1053 | 1062 | | |
1054 | 1063 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
384 | | - | |
385 | 384 | | |
386 | 385 | | |
387 | 386 | | |
| |||
527 | 526 | | |
528 | 527 | | |
529 | 528 | | |
530 | | - | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
531 | 536 | | |
532 | 537 | | |
533 | 538 | | |
| |||
Lines changed: 84 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2396 | 2396 | | |
2397 | 2397 | | |
2398 | 2398 | | |
| 2399 | + | |
| 2400 | + | |
| 2401 | + | |
| 2402 | + | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
| 2428 | + | |
| 2429 | + | |
2399 | 2430 | | |
2400 | 2431 | | |
2401 | 2432 | | |
| |||
7746 | 7777 | | |
7747 | 7778 | | |
7748 | 7779 | | |
7749 | | - | |
| 7780 | + | |
7750 | 7781 | | |
7751 | 7782 | | |
7752 | 7783 | | |
| |||
7755 | 7786 | | |
7756 | 7787 | | |
7757 | 7788 | | |
7758 | | - | |
| 7789 | + | |
| 7790 | + | |
| 7791 | + | |
| 7792 | + | |
| 7793 | + | |
| 7794 | + | |
| 7795 | + | |
| 7796 | + | |
7759 | 7797 | | |
7760 | 7798 | | |
7761 | 7799 | | |
| |||
8410 | 8448 | | |
8411 | 8449 | | |
8412 | 8450 | | |
| 8451 | + | |
| 8452 | + | |
| 8453 | + | |
| 8454 | + | |
| 8455 | + | |
| 8456 | + | |
| 8457 | + | |
| 8458 | + | |
| 8459 | + | |
| 8460 | + | |
| 8461 | + | |
| 8462 | + | |
8413 | 8463 | | |
8414 | 8464 | | |
8415 | 8465 | | |
| |||
9465 | 9515 | | |
9466 | 9516 | | |
9467 | 9517 | | |
| 9518 | + | |
| 9519 | + | |
| 9520 | + | |
| 9521 | + | |
| 9522 | + | |
| 9523 | + | |
| 9524 | + | |
| 9525 | + | |
| 9526 | + | |
| 9527 | + | |
| 9528 | + | |
| 9529 | + | |
| 9530 | + | |
9468 | 9531 | | |
9469 | 9532 | | |
9470 | 9533 | | |
| |||
9497 | 9560 | | |
9498 | 9561 | | |
9499 | 9562 | | |
| 9563 | + | |
| 9564 | + | |
| 9565 | + | |
| 9566 | + | |
| 9567 | + | |
| 9568 | + | |
| 9569 | + | |
| 9570 | + | |
| 9571 | + | |
| 9572 | + | |
| 9573 | + | |
| 9574 | + | |
| 9575 | + | |
9500 | 9576 | | |
9501 | 9577 | | |
9502 | 9578 | | |
| |||
9800 | 9876 | | |
9801 | 9877 | | |
9802 | 9878 | | |
| 9879 | + | |
| 9880 | + | |
| 9881 | + | |
| 9882 | + | |
| 9883 | + | |
| 9884 | + | |
9803 | 9885 | | |
9804 | 9886 | | |
9805 | 9887 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1315 | 1315 | | |
1316 | 1316 | | |
1317 | 1317 | | |
1318 | | - | |
| 1318 | + | |
1319 | 1319 | | |
1320 | 1320 | | |
1321 | | - | |
| 1321 | + | |
1322 | 1322 | | |
1323 | 1323 | | |
1324 | 1324 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| |||
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
0 commit comments