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

Do not allow variables to be self-assigned through initialization #436

Merged
merged 2 commits into from
Jun 29, 2019

Conversation

Daniel-Cortez
Copy link
Contributor

What this PR does / why we need it:

Fixes variables being able to be self-assigned through initialization expressions (#420).
Example:

main()
{
	// Before the fix: no error
	// After: error 017: undefined symbol "test"
	new test = test;
}

The problem is that the compiler creates symbol test before generating the code for its initialization expression, so test can be used in that expression.
This PR simply makes the compiler temporarily mark the newly created symbol as undefined (until the code for the initialization expression is emitted) and issue an error if the symbol for a local variable is undefined.

Which issue(s) this PR fixes:

Fixes #420

What kind of pull this is:

  • A Bug Fix
  • A New Feature
  • Some repository meta (documentation, etc)
  • Other

Additional Documentation:

@Daniel-Cortez Daniel-Cortez requested a review from a team as a code owner June 28, 2019 16:52
Daniel-Cortez added a commit to Daniel-Cortez/pawn-3.10 that referenced this pull request Jun 28, 2019
@Zeex Zeex merged commit 6356afb into pawn-lang:dev Jun 29, 2019
@Daniel-Cortez Daniel-Cortez deleted the fix-init-selfassignment branch June 29, 2019 13:58
Daniel-Cortez added a commit to Daniel-Cortez/pawn-3.10 that referenced this pull request Jul 20, 2019
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.

3 participants