type checker, phase 1: hints are checked where concrete

First slice of the static-typing foundation (traits/generics/Sized()
will build on it).  Typing stays structural and permissive: an unknown
or opaque name is never a rejection, so existing programs keep working.

- new module cat/types/type.{h,c}: compile-time-only descriptors
  (int/float/bool/text/empty/object/function/list/memory/any + interned
  named/opaque types), with equal/assignable/join and int->float widening.
- compiler: skip_type_hint -> parse_type_hint, which returns the type of
  the first identifier in a hint (the rest of a balanced hint is still
  consumed and ignored, so `cbyte[sentinel_sized<0>]` parses).
- `local NAME : T = <literal>` is checked: assigning a known concrete
  literal of the wrong kind to a known concrete type raises at compile
  time ("line N: cannot assign text to int").  Unknown/opaque names and
  non-literal expressions stay permissive.
- FuncCtx tracks a declared/inferred type per local slot.
- tests/types.cat + suite block: ok hints, int->float widening, opaque
  names accepted, and a wrong assignment rejected.  Suite 136 -> 140.
This commit is contained in:
Minus committed 2026-11-18 16:56:40 +00:00
1 parent b945182739
commit 48b1b84ea6
6 files changed
+309 -17

No files matched your search

+1
View File
@@ -32,6 +32,7 @@ SRCS := \
src/cat/vm.c \
src/cat/module.c \
src/cat/types/empty.c \
src/cat/types/type.c \
src/cat/types/bool.c \
src/cat/types/number.c \
src/cat/types/int.c \