type a macro call by what it expands to
A receiver, a scrutinee or the start of a path was typed before the walk had expanded it, so (.len (the a)) had no type to dispatch on and (. (the p) x) read a pointer as a value.
This commit is contained in:
@@ -125,6 +125,14 @@
|
||||
(test-assert "one that cannot change it takes it"
|
||||
(emits? (ops-src "(var c (* const vec2) p) (var n float (.length c))")
|
||||
"vec2ːlength(c)"))
|
||||
(test-assert "a macro receiver is typed by what it expands to"
|
||||
(emits? (string-append "(defmacro (the a) a)"
|
||||
(ops-src "(var n float (.length (the v)))"))
|
||||
"vec2ːlength(&v)"))
|
||||
(test-assert "and so is the start of a path"
|
||||
(emits? (string-append "(defmacro (the a) a)"
|
||||
(ops-src "(var q float (. (the p) x))"))
|
||||
"p->x"))
|
||||
(test-assert "an address cannot be taken of a call"
|
||||
(reports? (ops-src "(.length (mk))") "receiver is not an lvalue"))
|
||||
;; the inner call has to be typed to find the outer one's receiver
|
||||
@@ -285,6 +293,11 @@
|
||||
(test-assert "a path scrutinee is not copied"
|
||||
(not (emits? (sum-src "(match s ((circle (r)) (= out r)) (else (= out 0.0)))")
|
||||
"ƛm0")))
|
||||
(test-assert "a macro scrutinee is typed by what it expands to"
|
||||
(emits? (string-append "(defmacro (the a) a)"
|
||||
(sum-src "(match (the s) ((circle (r)) (= out r))"
|
||||
" (else (= out 0.0)))"))
|
||||
"shape ƛm0 = s"))
|
||||
(test-assert "else becomes default"
|
||||
(emits? (sum-src "(match s ((circle (r)) (= out r)) (else (= out 0.0)))")
|
||||
"default:"))
|
||||
|
||||
Reference in New Issue
Block a user