diff options
author | Eduardo Julian | 2021-09-15 01:52:03 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-09-15 01:52:03 -0400 |
commit | 86c04a4ce3be995edf14ae7f3bf1e137d478c40e (patch) | |
tree | d3bc5299e0e82b8253648d6abc8af79de77e5f89 /lux-bootstrapper/src/lux/analyser/module.clj | |
parent | fbecb061fb8530ad7d04e8e3f67605e2964822e4 (diff) |
Correctly analyzing records in the presence of local bindings.
Diffstat (limited to 'lux-bootstrapper/src/lux/analyser/module.clj')
-rw-r--r-- | lux-bootstrapper/src/lux/analyser/module.clj | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lux-bootstrapper/src/lux/analyser/module.clj b/lux-bootstrapper/src/lux/analyser/module.clj index 8c3a83440..1cf3f6f4f 100644 --- a/lux-bootstrapper/src/lux/analyser/module.clj +++ b/lux-bootstrapper/src/lux/analyser/module.clj @@ -520,3 +520,19 @@ _ (&/fail-with-loc "[Analyser Error] Incorrect import syntax."))) + +(defn find_local [name] + (fn [state] + (|let [stack (&/get$ &/$scopes state) + no-binding? #(and (->> % (&/get$ &/$locals) (&/get$ &/$mappings) (&/|contains? name) not) + (->> % (&/get$ &/$captured) (&/get$ &/$mappings) (&/|contains? name) not)) + [inner outer] (&/|split-with no-binding? stack)] + (|case outer + (&/$End) + (return* state &/$None) + + (&/$Item bottom-outer _) + (let [local (&/|second (or (->> bottom-outer (&/get$ &/$locals) (&/get$ &/$mappings) (&/|get name)) + (->> bottom-outer (&/get$ &/$captured) (&/get$ &/$mappings) (&/|get name))))] + (return* state (&/$Some (&/T [local (&/|reverse inner) outer])))) + )))) |