type checker, phase 2: return hints checked

- parse the `-> T` return hint into the function context (was consumed
  and dropped).
- `return <literal>` is checked against the declared return type: a
  concrete mismatch raises at compile time.  Opaque/unknown returns and
  non-literal expressions stay permissive.
- tests/types.cat + suite: a valid `-> int` function.  Suite 140 -> 141.
This commit is contained in:
Minus committed 2026-11-18 17:15:42 +00:00
1 parent 48b1b84ea6
commit 96e8f516cc
3 files changed
+19 -4

No files matched your search

+6
View File
@@ -18,3 +18,9 @@ print("widen:", f)
local n : cint = 42
local buf : cbyte[] = empty
print("opaque:", n, buf)
-- return type hints are checked where concrete
function good() -> int
return 5
end
print("ret:", good())