The script is in tools/ rather than thrown away, because two lanes are
writing Flan in the old spelling right now and their files need the same
pass at merge.
It works on forms, not on text: a keyword becomes a dot only where it sits
in a field-label position inside a brace, so an enum member in value
position, a map key inside an EDN string and a type-position {K V} are all
left alone. :keys keeps its colon -- it names no field.
28 lines
1.1 KiB
Plaintext
28 lines
1.1 KiB
Plaintext
;;;; A package-qualified struct in return position.
|
|
;;;;
|
|
;;;; The parser decides "is this form a return type or the first body form?"
|
|
;;;; from the set of type names the file declares — and an import is resolved
|
|
;;;; after parsing, so a package's structs cannot be in that set. The result
|
|
;;;; was that (defn mk [] rl/Vector2 ...) read the return type as the body and
|
|
;;;; failed with "unknown name rl/Vector2", which named the symptom and not the
|
|
;;;; cause. The alias plus the capital is the signal: a bare capitalised symbol
|
|
;;;; is never a value here, since a constructor is (Name {...}) and an enum
|
|
;;;; member is a keyword.
|
|
(import edn "vendor:edn")
|
|
|
|
(defstruct Local [n i32])
|
|
|
|
;;; The case that used to fail: a package struct as the declared return type.
|
|
(defn fresh [src [u8]] edn/Cursor (edn/cursor src))
|
|
|
|
;;; And the one that must keep working: a lowercase qualified name in the same
|
|
;;; position is an expression, not a type.
|
|
(defn local [] Local (Local {.n 5}))
|
|
|
|
(defn main [] i32
|
|
(let [c (fresh (bytes "[1 2]"))
|
|
t (edn/next (addr c))]
|
|
(print (.kind t)) (println ""))
|
|
(print (.n (local))) (println "")
|
|
0)
|