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 variable mutation in block #335

Merged
merged 1 commit into from
Oct 28, 2021
Merged

Conversation

CohenArthur
Copy link
Member

@CohenArthur CohenArthur commented Oct 28, 2021

When mutating a variable from a block, the interpreter would call the
replace_variable method, which would get a reference to the variable,
remove it, and then add a new one. However, this method wasn't scope-map
aware: While we were removing the correct variable from the outtermost
scope, we were adding the new one in the inner scope. An easy fix is to
instead mutate the variable we were originally getting.

Closes #187

When mutating a variable from a block, the interpreter would call the
`replace_variable` method, which would get a reference to the variable,
remove it, and then add a new one. However, this method wasn't scope-map
aware: While we were removing the correct variable from the outtermost
scope, we were adding the new one in the inner scope. An easy fix is to
instead mutate the variable we were originally getting.
@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2021

Codecov Report

Merging #335 (be6af25) into master (1babd52) will increase coverage by 0.00%.
The diff coverage is 92.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #335   +/-   ##
=======================================
  Coverage   92.97%   92.98%           
=======================================
  Files          41       41           
  Lines        4227     4233    +6     
=======================================
+ Hits         3930     3936    +6     
  Misses        297      297           
Impacted Files Coverage Δ
src/instruction/var_assignment.rs 90.00% <83.33%> (-0.68%) ⬇️
src/context.rs 94.24% <100.00%> (-0.03%) ⬇️
src/context/scope_map.rs 94.28% <100.00%> (+1.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1babd52...be6af25. Read the comment docs.

Copy link
Collaborator

@SanderJSA SanderJSA left a comment

Choose a reason for hiding this comment

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

tiny nitpick
otherwise lgtm

src/context/scope_map.rs Show resolved Hide resolved
@CohenArthur CohenArthur merged commit c370d1b into master Oct 28, 2021
@CohenArthur CohenArthur deleted the 187-mutate-var-in-block branch October 28, 2021 07:50
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.

Mutating variable in block creates new variable
3 participants