Skip to content

Conversation

@janiewang26
Copy link
Contributor

@janiewang26 janiewang26 commented Jun 25, 2020

Q                       A
Fixed Issues? Fixes #11475
Patch: Bug Fix? Yes
Major: Breaking Change? No
Minor: New Feature? No
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes? No
License MIT

Fix the bug where changing the value of constant variable in a loop will not output a read-only error.

Input

for (const element of array) {
  const from = 50;
  from--;
}

Output


var array = [1, 2, 3];
console.log("this file runs");

for (var element of []) {
  var from = 50;
  _readOnlyError("from"), from--;
}

@babel-bot
Copy link
Collaborator

babel-bot commented Jun 25, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/25130/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 25, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 480a272:

Sandbox Source
affectionate-fire-ev9r1 Configuration
great-worker-b26i5 Configuration

@JLHwung JLHwung changed the title Gh issue 11475 throw constant violations in loop body Jun 25, 2020
@JLHwung JLHwung added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Jun 25, 2020
@kaicataldo
Copy link
Member

Can you rebase this? It's currently undoing a recent PR.

@janiewang26
Copy link
Contributor Author

Rebased!

@JLHwung JLHwung self-requested a review July 2, 2020 16:34
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 8, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No assignment to constant variable error

4 participants