Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 56s
Parser hk-parse-parens gains a `::` arm after the first inner expression: consume `::`, parse a type via the existing hk-parse-type, expect `)`, emit (:type-ann EXPR TYPE). Sections, tuples, parenthesised expressions and unit `()` are unchanged. Desugar drops the annotation — :type-ann E _ → (hk-desugar E) — since the existing eval path has no type-directed dispatch. Phase 20 will extend infer.sx to consume the annotation and unify against the inferred type. tests/parse-extras.sx (12/12) covers literal, arithmetic, function arg, string, bool, tuple, nested annotation, function-typed annotation, and no-regression checks for plain parens / 3-tuples / left+right sections. eval (66/0), exceptions (14/0), typecheck (15/0), records (14/0), ioref (13/0) all still clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
64 lines
1.4 KiB
Plaintext
64 lines
1.4 KiB
Plaintext
;; Phase 17 — parser polish unit tests.
|
|
|
|
(hk-test
|
|
"type-ann: literal int annotated"
|
|
(hk-deep-force (hk-run "main = (42 :: Int)"))
|
|
42)
|
|
|
|
(hk-test
|
|
"type-ann: arithmetic annotated"
|
|
(hk-deep-force (hk-run "main = (1 + 2 :: Int)"))
|
|
3)
|
|
|
|
(hk-test
|
|
"type-ann: function arg annotated"
|
|
(hk-deep-force
|
|
(hk-run "f x = x + 1\nmain = f (1 :: Int)"))
|
|
2)
|
|
|
|
(hk-test
|
|
"type-ann: string annotated"
|
|
(hk-deep-force (hk-run "main = (\"hi\" :: String)"))
|
|
"hi")
|
|
|
|
(hk-test
|
|
"type-ann: bool annotated"
|
|
(hk-deep-force (hk-run "main = (True :: Bool)"))
|
|
(list "True"))
|
|
|
|
(hk-test
|
|
"type-ann: tuple annotated"
|
|
(hk-deep-force (hk-run "main = ((1, 2) :: (Int, Int))"))
|
|
(list "Tuple" 1 2))
|
|
|
|
(hk-test
|
|
"type-ann: nested annotation in arithmetic"
|
|
(hk-deep-force (hk-run "main = (1 :: Int) + (2 :: Int)"))
|
|
3)
|
|
|
|
(hk-test
|
|
"type-ann: function-typed annotation passes through eval"
|
|
(hk-deep-force
|
|
(hk-run "main = let f = ((\\x -> x + 1) :: Int -> Int) in f 5"))
|
|
6)
|
|
|
|
(hk-test
|
|
"no regression: plain parens still work"
|
|
(hk-deep-force (hk-run "main = (5)"))
|
|
5)
|
|
|
|
(hk-test
|
|
"no regression: 3-tuple still works"
|
|
(hk-deep-force (hk-run "main = (1, 2, 3)"))
|
|
(list "Tuple" 1 2 3))
|
|
|
|
(hk-test
|
|
"no regression: section-left still works"
|
|
(hk-deep-force (hk-run "main = (3 +) 4"))
|
|
7)
|
|
|
|
(hk-test
|
|
"no regression: section-right still works"
|
|
(hk-deep-force (hk-run "main = (+ 3) 4"))
|
|
7)
|