From 0f7bfa0d4a4e5a79fffe72adec1dd35992c7dde3 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sun, 5 Sep 2021 15:17:20 -0400 Subject: Clearing the local scope during eval analysis to avoid accidentally seeing variables outside of eval's scope. --- .../library/lux/tool/compiler/language/lux/analysis.lux | 15 +++++++++++++++ .../tool/compiler/language/lux/analysis/evaluation.lux | 5 +++-- stdlib/source/library/lux/type.lux | 7 +++---- 3 files changed, 21 insertions(+), 6 deletions(-) (limited to 'stdlib') 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)))))] -- cgit v1.2.3