test/951: add str->u8 reject rows at let + struct-field (#251)
The reject table exercised the non-foldable element-type branch only at the def site; let and struct-field covered the foldable range branch alone. Add let_str and struct_str so both reject branches (foldable out-of-range int, non-foldable str) fire at all 3 wiring sites. A rune>u8 over-range row stays unexpressible: the lexer caps rune escapes at \xFF and does not decode multi-byte UTF-8 in a rune literal.
This commit is contained in:
@@ -42,11 +42,19 @@
|
||||
* - struct_int `enc{m=[65,..]}; E.m[0]` → 65
|
||||
* - struct_rune `enc{m=['A',..]}; E.m[1]` → 66
|
||||
*
|
||||
* Reject rows (must FAIL build on BOTH stages — rule-7 loud reject):
|
||||
* - let_over `let a:[2]u8=[300,1]` (out of range)
|
||||
* - def_over `def D:[2]u8=[300,1]` (was a wwstage over-accept)
|
||||
* - struct_over `enc{m=[300,1]}` (was a wwstage over-accept)
|
||||
* - def_str `def D:[2]u8=["x","y"]` (was a wwstage over-accept)
|
||||
* Reject rows (must FAIL build on BOTH stages — rule-7 loud reject).
|
||||
* Two reject branches per the predicate: the FOLDABLE range-check
|
||||
* (out-of-range int) and the NON-FOLDABLE element-type check (str→u8),
|
||||
* each exercised at all 3 sites. (A rune>u8 over-range row is not
|
||||
* expressible: the ww lexer caps rune escapes at \xFF=255 and does not
|
||||
* decode multi-byte UTF-8 in a rune literal, so every rune literal
|
||||
* already fits u8 — the foldable branch is identical for int and rune.)
|
||||
* - let_over `let a:[2]u8=[300,1]` (foldable: out of range)
|
||||
* - def_over `def D:[2]u8=[300,1]` (foldable: was a ww over-accept)
|
||||
* - struct_over `enc{m=[300,1]}` (foldable: was a ww over-accept)
|
||||
* - let_str `let a:[2]u8=["x","y"]` (non-foldable: str→u8)
|
||||
* - def_str `def D:[2]u8=["x","y"]` (non-foldable: was a ww over-accept)
|
||||
* - struct_str `enc{m=["x","y"]}` (non-foldable: was a ww over-accept)
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -116,10 +124,18 @@ static const struct rrow reject_rows[] = {
|
||||
"type enc = struct { m: [2]u8 };\n"
|
||||
"let E: enc = enc { m = [300, 1] };\n"
|
||||
"export fn main() i32 = { return E.m[0]: i32; };\n" },
|
||||
{ "let_str",
|
||||
"package main;\n"
|
||||
"export fn main() i32 = { let a: [2]u8 = [\"x\", \"y\"]; return a[0]: i32; };\n" },
|
||||
{ "def_str",
|
||||
"package main;\n"
|
||||
"def D: [2]u8 = [\"x\", \"y\"];\n"
|
||||
"export fn main() i32 = { return 0; };\n" },
|
||||
{ "struct_str",
|
||||
"package main;\n"
|
||||
"type enc = struct { m: [2]u8 };\n"
|
||||
"let E: enc = enc { m = [\"x\", \"y\"] };\n"
|
||||
"export fn main() i32 = { return E.m[0]: i32; };\n" },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user