diff options
author | Eduardo Julian | 2019-10-17 20:51:39 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-10-17 20:51:39 -0400 |
commit | 94e5a6b6ce7ad4b103e9d55c1aad2bd376f5da67 (patch) | |
tree | 974e189415868dc8feb6fb151ae07ab6e594e24f | |
parent | 299908a885d00ec735070a937f9720410fe224a9 (diff) |
FIX old compiler could allow aliases to be defined more than once
Diffstat (limited to '')
-rw-r--r-- | luxc/src/lux/analyser/lux.clj | 14 | ||||
-rw-r--r-- | stdlib/source/lux/target/jvm/field.lux | 2 | ||||
-rw-r--r-- | stdlib/source/lux/tool/compiler/phase/analysis/module.lux | 2 |
3 files changed, 11 insertions, 7 deletions
diff --git a/luxc/src/lux/analyser/lux.clj b/luxc/src/lux/analyser/lux.clj index eb412bf0c..fee56b624 100644 --- a/luxc/src/lux/analyser/lux.clj +++ b/luxc/src/lux/analyser/lux.clj @@ -541,12 +541,15 @@ (|do [output (analyse-function** analyse exo-type ?self ?arg ?body)] (return (&/|list output)))) +(defn ^:private ensure-undefined! [module-name local-name] + (|do [verdict (&&module/defined? module-name local-name)] + (&/assert! (not verdict) + (str "[Analyser Error] Cannot re-define " module-name &/+name-separator+ local-name)))) + (defn analyse-def* [analyse optimize eval! compile-def ?name ?value ?meta exported? & [?expected-type]] (|do [_ &/ensure-directive module-name &/get-module-name - ? (&&module/defined? module-name ?name) - _ (&/assert! (not ?) - (str "[Analyser Error] Cannot re-define " (str module-name &/+name-separator+ ?name))) + _ (ensure-undefined! module-name ?name) =value (&/without-repl-closure (&/with-scope ?name (if ?expected-type @@ -580,8 +583,9 @@ (defn analyse-def-alias [?alias ?original] (|let [[r-module r-name] ?original] - (|do [_ (&&module/find-def r-module r-name) - module-name &/get-module-name + (|do [module-name &/get-module-name + _ (ensure-undefined! module-name ?alias) + _ (&&module/find-def r-module r-name) _ (&/without-repl-closure (&&module/define-alias module-name ?alias ?original))] (return &/$Nil)))) diff --git a/stdlib/source/lux/target/jvm/field.lux b/stdlib/source/lux/target/jvm/field.lux index 3f569502a..1e7edac35 100644 --- a/stdlib/source/lux/target/jvm/field.lux +++ b/stdlib/source/lux/target/jvm/field.lux @@ -1,5 +1,5 @@ (.module: - [lux (#- static) + [lux (#- Type static) [abstract [monoid (#+)] ["." equivalence (#+ Equivalence)] diff --git a/stdlib/source/lux/tool/compiler/phase/analysis/module.lux b/stdlib/source/lux/tool/compiler/phase/analysis/module.lux index bb1094b2a..a6e1bedbd 100644 --- a/stdlib/source/lux/tool/compiler/phase/analysis/module.lux +++ b/stdlib/source/lux/tool/compiler/phase/analysis/module.lux @@ -136,7 +136,7 @@ []]) (#.Some already-existing) - ((/.throw' cannot-define-more-than-once [self-name name]) state)))))) + ((/.throw' ..cannot-define-more-than-once [self-name name]) state)))))) (def: #export (create hash name) (-> Nat Text (Operation Any)) |