Commit 68d9f66
reinterpret: centralize validation in emit so invalid casts fail cleanly
The shape helpers and pack/unpack tfuncs ran inside the kernel-inferred
path, where two failure modes produced confusing errors:
- A tfunc returning `nothing` on an indivisible width left the result
untypable, surfacing downstream as `internal error: invalid terminators`.
- A `throw(ArgumentError(...))` in a shape helper became an unsupported
`String` in kernel IR (`format_string`/`unsupported String` error),
masking the intended message.
Make both layers total: pack/unpack tfuncs always return a concrete type
(via `fld`), and the shape helpers are pure arithmetic. Validation now
lives solely in the pack/unpack/reshape emit, which throws a clear
`IRError` (e.g. "unpack: 1 bytes do not evenly divide into Float32").
Valid reinterprets are unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 436487d commit 68d9f66
1 file changed
Lines changed: 6 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
| 86 | + | |
88 | 87 | | |
89 | 88 | | |
90 | 89 | | |
| |||
132 | 131 | | |
133 | 132 | | |
134 | 133 | | |
135 | | - | |
136 | | - | |
| 134 | + | |
137 | 135 | | |
138 | 136 | | |
139 | 137 | | |
| |||
194 | 192 | | |
195 | 193 | | |
196 | 194 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
| 195 | + | |
| 196 | + | |
204 | 197 | | |
205 | 198 | | |
206 | 199 | | |
| |||
209 | 202 | | |
210 | 203 | | |
211 | 204 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
| 205 | + | |
| 206 | + | |
224 | 207 | | |
225 | 208 | | |
226 | 209 | | |
| |||
0 commit comments