sema/10-types #15
Loading…
Reference in a new issue
No description provided.
Delete branch "sema/10-types"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
`sema::types::Type` and its normalizing constructors, per docs/semantics/10-types.md. The first thing in the compiler that can say `int` and `s32` are the same type, and that `?int` and `int | null` are the same type. `Type` has no optional case, no alias case, and no error case. `?T` is `union_of([T, Null])`; `int` is `Int { bits: 32, signed: true }`; a body that fails to type is dropped from the HIR rather than poisoning every rule with an arm for "we gave up". `union_of` is the only way to build a union. It flattens, deduplicates, and sorts by the derived `Ord`, so `(a|b)|c` and `a|(b|c)` are one value and `==` is the whole story. `ids.rs` carries `DefId` and `TypeVar`, which `types` and (at step 20) `hir` both need. `TargetLayout`/`TARGET` is the interim answer to open spec question 4 and the single call site for `size_t`'s width. Six inline unit tests, no fixtures. Suite unchanged apart from those: the one failure is still the `.known-red` fixture driver.Open spec question 4 resolved, so step 10's `TargetLayout { pointer_bits: 64 }` placeholder goes away. `sema/src/target.rs` resolves an LLVM target triple into an `Arch`, a `DataModel`, and a `c_longdouble` width, and refuses one it cannot answer for with a message naming what it could not answer. `build.rs` writes the host triple into the binary, so the default is the platform the compiler was actually built for and the suite checks it rather than taking it on faith. Every target-dependent width moves onto `TargetLayout`: `size_t`, `ptrdiff_t`, and the eight integral `c_*` types. `IntType` keeps `s8 .. u128`, which no target changes. That closes the `c_*` gap step 10 shipped with — the twelve ABI types its Rules cite but its Functions list had no home for. `FloatWidth` grows `F80` and `F128` so `c_longdouble` has somewhere to land. Neither is spellable: there is no `f80` keyword and no plan for one. `TARGET` stays a global because nothing threads a target yet. `TargetLayout` is an ordinary value and `from_triple` is public, so the CLI's eventual `--target` passes one down and the static goes away. Five new unit tests in `target.rs`. Suite otherwise unchanged; the one failure is still the `.known-red` fixture driver.