forked from alex-eg/sex
refuse a variant named like a C keyword
One with fields is a member of the sum's union, and C takes no member named int; one without is held to the same, as one rule.
This commit is contained in:
@@ -505,6 +505,14 @@ ahead of its pub forms."
|
||||
" (match t ((circle (r)) (return 1)) (else (return 0)))))")
|
||||
"t.tag == shapeǂcircle"))
|
||||
;; a pointer to one was refused, where `.' reads through one
|
||||
;; a variant with fields is a member of the sum's union, which C
|
||||
;; would not take named `int'
|
||||
(test-assert "a variant named like a C keyword is refused"
|
||||
(reports? "(sum tok ((int ((v int))) (other ())))" "a variant cannot be named like a C keyword"))
|
||||
(test-assert "one without fields too, to keep one rule"
|
||||
(reports? "(sum tok ((default ()) (other ())))" "a variant cannot be named like a C keyword"))
|
||||
(test-assert "and stdbool's names count"
|
||||
(reports? "(sum b ((true ()) (false ())))" "a variant cannot be named like a C keyword"))
|
||||
(test-assert "a pointer to a sum is matched as the sum"
|
||||
(emits? (sum-src "(var p (* shape) (& s))"
|
||||
"(match p ((circle (r)) (= out r)) (else (= out 0.0)))")
|
||||
|
||||
Reference in New Issue
Block a user