Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: global access from defun declarations #530

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/corset/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ func (r *resolver) finaliseDefInRangeInModule(enclosing Scope, decl *DefInRange)
// accessed; (d) finally, resolving any parameters used within the body of this
// function.
func (r *resolver) finaliseDefFunInModule(enclosing Scope, decl *DefFun) []SyntaxError {
var scope = NewLocalScope(enclosing, false, decl.IsPure())
var scope = NewLocalScope(enclosing, true, decl.IsPure())
// Declare parameters in local scope
for _, p := range decl.Parameters() {
scope.DeclareLocal(p.Binding.name, &p.Binding)
Expand Down
4 changes: 4 additions & 0 deletions pkg/test/valid_corset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,10 @@ func Test_Lookup_09(t *testing.T) {
Check(t, false, "lookup_09")
}

func Test_Lookup_10(t *testing.T) {
Check(t, false, "lookup_10")
}

// ===================================================================
// Interleaving
// ===================================================================
Expand Down
41 changes: 41 additions & 0 deletions testdata/lookup_10.accepts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ "m1.X": [], "m1.Y": [] }
{ "m1.X": [0], "m1.Y": [0] }
{ "m1.X": [0], "m1.Y": [1] }
{ "m1.X": [1], "m1.Y": [2] }
{ "m1.X": [2], "m1.Y": [4] }
;;
{ "m1.X": [0,0], "m1.Y": [0,0] }
{ "m1.X": [0,0], "m1.Y": [1,2] }
{ "m1.X": [1,0], "m1.Y": [1,2] }
{ "m1.X": [0,1], "m1.Y": [1,2] }
{ "m1.X": [1,1], "m1.Y": [1,2] }
{ "m1.X": [0,0], "m1.Y": [2,1] }
{ "m1.X": [1,0], "m1.Y": [2,1] }
{ "m1.X": [0,1], "m1.Y": [2,1] }
{ "m1.X": [1,1], "m1.Y": [2,1] }
{ "m1.X": [0,0], "m1.Y": [2,2] }
{ "m1.X": [1,0], "m1.Y": [2,2] }
{ "m1.X": [0,1], "m1.Y": [2,2] }
{ "m1.X": [1,1], "m1.Y": [2,2] }
;;
{ "m1.X": [0,0], "m1.Y": [0,0] }
{ "m1.X": [0,0], "m1.Y": [1,4] }
{ "m1.X": [2,0], "m1.Y": [1,4] }
{ "m1.X": [0,2], "m1.Y": [1,4] }
{ "m1.X": [2,2], "m1.Y": [1,4] }
{ "m1.X": [0,0], "m1.Y": [4,1] }
{ "m1.X": [2,0], "m1.Y": [4,1] }
{ "m1.X": [0,2], "m1.Y": [4,1] }
{ "m1.X": [2,2], "m1.Y": [4,1] }
{ "m1.X": [0,0], "m1.Y": [4,4] }
{ "m1.X": [2,0], "m1.Y": [4,4] }
{ "m1.X": [0,2], "m1.Y": [4,4] }
{ "m1.X": [2,2], "m1.Y": [4,4] }
;;
{ "m1.X": [1,2,3], "m1.Y": [2,4,6] }
{ "m1.X": [2,1,3], "m1.Y": [2,4,6] }
{ "m1.X": [1,3,2], "m1.Y": [2,4,6] }
{ "m1.X": [1,2,3], "m1.Y": [4,2,6] }
{ "m1.X": [1,2,3], "m1.Y": [2,6,4] }
{ "m1.X": [1,2,3], "m1.Y": [6,4,2] }
{ "m1.X": [1,2,3], "m1.Y": [6,2,4] }
5 changes: 5 additions & 0 deletions testdata/lookup_10.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(defun (selector) (* m1.X 2))

(module m1)
(defcolumns X Y)
(deflookup test (Y) ((selector)))
18 changes: 18 additions & 0 deletions testdata/lookup_10.rejects
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{ "m1.X": [1], "m1.Y": [1] }
{ "m1.X": [2], "m1.Y": [1] }
{ "m1.X": [3], "m1.Y": [1] }
{ "m1.X": [1], "m1.Y": [3] }
{ "m1.X": [1], "m1.Y": [4] }
{ "m1.X": [1], "m1.Y": [5] }
{ "m1.X": [2], "m1.Y": [2] }
{ "m1.X": [2], "m1.Y": [3] }
{ "m1.X": [2], "m1.Y": [5] }
{ "m1.X": [1,0], "m1.Y": [1,1] }
{ "m1.X": [1,0], "m1.Y": [1,3] }
{ "m1.X": [1,0], "m1.Y": [1,4] }
{ "m1.X": [0,1], "m1.Y": [1,1] }
{ "m1.X": [0,1], "m1.Y": [1,3] }
{ "m1.X": [0,1], "m1.Y": [1,4] }
{ "m1.X": [1,1], "m1.Y": [1,1] }
{ "m1.X": [1,1], "m1.Y": [1,3] }
{ "m1.X": [1,1], "m1.Y": [1,4] }
Loading