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

Runtime panic on self assignment #386

Closed
beoran opened this issue Jul 10, 2022 · 3 comments · Fixed by #387
Closed

Runtime panic on self assignment #386

beoran opened this issue Jul 10, 2022 · 3 comments · Fixed by #387

Comments

@beoran
Copy link

beoran commented Jul 10, 2022

The following Tengo script panics at run time:

a := a.foo

This likely because the compiler wrongly considers a to be defined after the := . A should only be considered defined in the next statement.

@geseq
Copy link
Collaborator

geseq commented Jul 10, 2022

Right, this is a problem, but I'm not sure your solution would work. It would break recursive functions.

@beoran
Copy link
Author

beoran commented Jul 10, 2022

For a func block, an exception can be made to the rule I propose that the variable is defined inside there.

Edit: Or, the semantics could stay the same as now, but then a.foo should return undefined in stead of panicking.

@beoran
Copy link
Author

beoran commented Jul 20, 2022

Thanks for the fix!

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 a pull request may close this issue.

2 participants