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

evaluator: Don't nest function scope inside other function scope #128

Merged
merged 1 commit into from
Apr 30, 2023

Conversation

camh-
Copy link
Member

@camh- camh- commented Apr 30, 2023

Do not nest a function scope inside another function scope, since we do
not look up variables across function scopes. A function scope should be
based on the global scope only (and this includes handler scopes too,
which are just a function in disguise).

This program would print "2" instead of "1" as f2 was traversing the
scope of f1 when looking up a to print. It should skip f1 and go
straight to the global scope:

a := 1
func f1
  a := 2
  f2
end
func f2
  print a
end
f1

@github-actions
Copy link

github-actions bot commented Apr 30, 2023

firebase-deployment: https://evy-lang--128-lq8bmabv.web.app (63e8b8a)

@camh- camh- requested a review from juliaogris April 30, 2023 03:59
Copy link
Member

@juliaogris juliaogris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💚

print f
if true
f := "🎈"
print f
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation seems a little off I think.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. fixed I think. I had tab indenting when it was at 8-spaces, which perhaps you saw as 4 spaces depending on your github settings.

Do not nest a function scope inside another function scope, since we do
not look up variables across function scopes. A function scope should be
based on the global scope only (and this includes handler scopes too,
which are just a function in disguise).

This program would print "2" instead of "1" as `f2` was traversing the
scope of `f1` when looking up `a` to print. It should skip `f1` and go
straight to the global scope:

    a := 1
    func f1
      a := 2
      f2
    end
    func f2
      print a
    end
    f1
@camh- camh- merged commit a702cc8 into master Apr 30, 2023
@camh- camh- deleted the fix-eval-func-scope branch June 14, 2023 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants