aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2021-09-05 15:17:20 -0400
committerEduardo Julian2021-09-05 15:17:20 -0400
commit0f7bfa0d4a4e5a79fffe72adec1dd35992c7dde3 (patch)
tree27b53f1d9f5e7c1b7a548fb7c10b9b7bfda42fe8 /stdlib
parent54c0e9c7397908eeddf5fbed9b193e25648fb253 (diff)
Clearing the local scope during eval analysis to avoid accidentally seeing variables outside of eval's scope.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux15
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux5
-rw-r--r--stdlib/source/library/lux/type.lux7
3 files changed, 21 insertions, 6 deletions
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux
index 772b0b04d..5522749e0 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux
@@ -447,6 +447,21 @@
(#try.Failure error)
(#try.Failure error))))
+(def: scope_reset
+ (List Scope)
+ (list fresh_scope))
+
+(def: .public (without_scopes action)
+ (All (_ a) (-> (Operation a) (Operation a)))
+ (function (_ [bundle state])
+ (case (action [bundle (with@ #.scopes ..scope_reset state)])
+ (#try.Success [[bundle' state'] output])
+ (#try.Success [[bundle' (with@ #.scopes (value@ #.scopes state) state')]
+ output])
+
+ (#try.Failure error)
+ (#try.Failure error))))
+
(def: .public (with_current_module name)
(All (_ a) (-> Text (Operation a) (Operation a)))
(extension.localized (value@ #.current_module)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux
index a770d7798..94305f30a 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux
@@ -9,7 +9,7 @@
[math
[number
["n" nat]]]]]
- [// {"+" [Operation]}
+ ["." // {"+" [Operation]}
[macro {"+" [Expander]}]
[//
[phase
@@ -45,7 +45,8 @@
(function (eval archive type exprC)
(do phase.monad
[exprA (type.with_type type
- (analyze archive exprC))
+ (//.without_scopes
+ (analyze archive exprC)))
module (extensionP.lifted
meta.current_module_name)
count (extensionP.lifted
diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux
index c6f57f52f..c60be0b73 100644
--- a/stdlib/source/library/lux/type.lux
+++ b/stdlib/source/library/lux/type.lux
@@ -445,10 +445,9 @@
exemplar ..typed
computation ..typed])
(macro.with_identifiers [g!_]
- (let [typeC (("lux in-module" "library/lux" .quantified)
- (` (All ((~ g!_) (~+ (list\each code.local_identifier type_vars)))
- (-> (~ (value@ #type exemplar))
- (~ (value@ #type computation))))))
+ (let [typeC (` (All ((~ g!_) (~+ (list\each code.local_identifier type_vars)))
+ (-> (~ (value@ #type exemplar))
+ (~ (value@ #type computation)))))
shareC (` (: (~ typeC)
(.function ((~ g!_) (~ g!_))
(~ (value@ #expression computation)))))]