walk what an initializer holds
The body walk passed a #(...) by as an atom, so nothing inside one was typed, dispatched or lifted: (. self p) read as self.p with self a pointer, where the same path outside the literal was right. Fixes #45.
This commit is contained in:
@@ -798,6 +798,18 @@ whitespace aside, THEN?"
|
||||
|
||||
;; `.' is C's `.' or its `->' depending on what is being read from,
|
||||
;; so a path reads the same however the thing it starts from is held
|
||||
;; ...and inside a literal, which the walk used to pass by
|
||||
(test-group "member access in a literal"
|
||||
(test-assert "compound"
|
||||
(emits? (in-line "(var q (struct point) #(struct point : (. pp x) (. pp y)))")
|
||||
"(struct point){pp->x, pp->y}"))
|
||||
(test-assert "brace initializer"
|
||||
(emits? (in-line "(var q (struct point) #((. pp x) (. pp y)))")
|
||||
"{pp->x, pp->y}"))
|
||||
(test-assert "designated"
|
||||
(emits? (in-line "(var q (struct point) #(.y (. pp x)))")
|
||||
"{.y = pp->x}")))
|
||||
|
||||
(test-group "member access"
|
||||
(test-assert "a value reads with a dot"
|
||||
(emits? (in-line "(= (. p x) 1)") "p.x = 1"))
|
||||
|
||||
Reference in New Issue
Block a user