A constant's slice part may name another module's array constant constPart took the whole constant only by its bare name, by the length of its text; Widths.Wide failed. It now asks for the constant's own type, which a part of it, an element or a slice, hasn't.
| @@ -3,3 +3,5 @@ | ||
| 3 | 3 | wide 1 |
| 4 | 4 | narrow 0 |
| 5 | 5 | none 0 |
| 6 | +Widths.Wide 3 | |
| 7 | +Widths.Narrow 0 |
| @@ -10,7 +10,8 @@ | ||
| 10 | 10 | None: []I64 = []; |
| 11 | 11 | Wide: [][2]I32 = [[1100H, 115FH]]; |
| 12 | 12 | Narrow: [][2]I32 = []; |
| 13 | - Props: []Prop = [{name: "wide", runs: Wide}, {name: "narrow", runs: Narrow}, {name: "none", runs: []}]; | |
| 13 | + Props: []Prop = [{name: "wide", runs: Wide}, {name: "narrow", runs: Narrow}, {name: "none", runs: []}, | |
| 14 | + {name: "Widths.Wide", runs: Widths.Wide}, {name: "Widths.Narrow", runs: Widths.Narrow}]; | |
| 14 | 15 | |
| 15 | 16 | proc sum(a: []I64): I64; |
| 16 | 17 | var s: I64; i: INT; |
| @@ -20,7 +20,7 @@ | ||
| 20 | 20 | | `src/X64.raz` | 1,517 | 1,253 | The instruction encoder, jumps within a procedure, the assembler | |
| 21 | 21 | | `src/Gen.raz` | 2,552 | 1,821 | The stack machine, for x86-64: values, operations, checks, calls, frames | |
| 22 | 22 | | `src/Item.raz` | 2,037 | 1,651 | Items: types, constants, variables, operators, conversions, calls | |
| 23 | -| `src/Parse.raz` | 4,175 | 3,616 | Declarations, statements, expressions, built-ins, recovery, warnings | | |
| 23 | +| `src/Parse.raz` | 4,176 | 3,615 | Declarations, statements, expressions, built-ins, recovery, warnings | | |
| 24 | 24 | | `src/Link.raz` | 381 | 298 | Tree shaking, layout, patching, the places | |
| 25 | 25 | | `src/Elf.raz` | 431 | 344 | Static and dynamic ELF, symbol table, line numbers | |
| 26 | 26 | | `src/Raz.raz` | 305 | 238 | The command line | |
| @@ -3234,9 +3234,10 @@ | ||
| 3234 | 3234 | COPY(constBytes[off..off + INT(e.val)], Chunk.rodata[st..st + INT(e.val)]); |
| 3235 | 3235 | end; |
| 3236 | 3236 | elsif t^.form = Sym.fSlice then |
| 3237 | - if (e.mode # Item.mVar) or (e.obj = nil) or (e.obj^.cls # Sym.oConst) | |
| 3238 | - or not (e.typ^.form in {Sym.fArray, Sym.fSlice}) | |
| 3239 | - or (e.pos.b - e.pos.a # LEN(nameOf(e.obj^.name))) or not Sym.same(e.typ^.base, t^.base) then | |
| 3237 | + (* the whole constant, here or another module's, not a part of | |
| 3238 | + it, which has a type of its own: the element's, or a slice's *) | |
| 3239 | + if (e.mode # Item.mVar) or (e.obj = nil) or (e.obj^.cls # Sym.oConst) or (e.typ # e.obj^.typ) | |
| 3240 | + or not (e.typ^.form in {Sym.fArray, Sym.fSlice}) or not Sym.same(e.typ^.base, t^.base) then | |
| 3240 | 3241 | return Scan.markAt(e.pos, say1("a constant slice is a string, an array constant of its elements or [], found {}", Item.what(e))); |
| 3241 | 3242 | end; |
| 3242 | 3243 | if e.typ^.form = Sym.fArray then (* else an empty slice constant, whose bytes stay zero *) |
| @@ -1,2 +1,2 @@ | ||
| 1 | -conform/run/EmptySliceConst.raz:34:18: index 0 is out of range for a length of 0 | |
| 2 | - in EmptySliceConst.main at conform/run/EmptySliceConst.raz:34:18: i = 0 | |
| 1 | +conform/run/EmptySliceConst.raz:35:18: index 0 is out of range for a length of 0 | |
| 2 | + in EmptySliceConst.main at conform/run/EmptySliceConst.raz:35:18: i = 0 |