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

🪲 Variable access before definition error raised incorrectly #5728

Closed
boryanagoncharenko opened this issue Aug 29, 2024 · 1 comment · Fixed by #5793
Closed

🪲 Variable access before definition error raised incorrectly #5728

boryanagoncharenko opened this issue Aug 29, 2024 · 1 comment · Fixed by #5793
Assignees
Labels
bug Something isn't working language Issues related to the Hedy language

Comments

@boryanagoncharenko
Copy link
Collaborator

Describe the bug
In some cases a command could consider an argument either as a variable, if such is defined, or a literal string. If a variable is defined and if is accessed before its definition, an error is raised. The access-before-definition check uses only line numbers. As a result, the following snippet produces an error while it should not.

Paste the Hedy code & level
Level 12:

define turn
    if x is pressed
        print 'good'
    else
        print 'bad'

print 'Start'
call turn
x is 1 + 1
print x
print 'End'

The access-before-definition check should take into account that functions use another scope.

@boryanagoncharenko boryanagoncharenko added the bug Something isn't working label Aug 29, 2024
@boryanagoncharenko boryanagoncharenko added the language Issues related to the Hedy language label Aug 29, 2024
@boryanagoncharenko
Copy link
Collaborator Author

This issue is tightly-coupled to #5749

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working language Issues related to the Hedy language
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

1 participant