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: creating duplicate params via renaming vars #6885

Merged
merged 10 commits into from
Mar 9, 2023

Conversation

BeksOmega
Copy link
Collaborator

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Fixes #3767

Proposed Changes

Adds a step to renameVariable that detects if a variable rename will create a parameter conflict.

Detects conflicts in legacy procedure blocks by walking the workspace, and conflicts in procedure models by checking if the parameter wraps a variable model.

Alternative implementations discussed here: #3767 (comment)

Reason for Changes

Squash de buggies

Test Coverage

Added tests for nameUsedWithConflictingParam for both legacy procedure blocks and procedure models.

Documentation

N/A

Additional Information

Best reviewed commit-wise, especially because I reorganize some code to return-early instead of deeply nesting.

@BeksOmega BeksOmega requested a review from a team as a code owner March 6, 2023 21:18
@BeksOmega BeksOmega requested a review from gonfunko March 6, 2023 21:18
@github-actions github-actions bot added the PR: fix Fixes a bug label Mar 6, 2023
@BeksOmega BeksOmega requested review from maribethb and removed request for gonfunko March 6, 2023 21:19
@BeksOmega BeksOmega assigned maribethb and unassigned gonfunko Mar 6, 2023
core/variables.ts Show resolved Hide resolved
core/interfaces/i_legacy_procedure_blocks.ts Show resolved Hide resolved
core/variables.ts Outdated Show resolved Hide resolved
core/variables.ts Outdated Show resolved Hide resolved
core/interfaces/i_legacy_procedure_blocks.ts Show resolved Hide resolved
tests/mocha/blocks/variables_test.js Outdated Show resolved Hide resolved
core/interfaces/i_variable_holder.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@maribethb maribethb left a comment

Choose a reason for hiding this comment

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

Please fix lint warning, then lgtm

@BeksOmega
Copy link
Collaborator Author

Fixed lint, and set it to error since we want to enforce it! Please tell me if you want me to revert that change.

@BeksOmega BeksOmega merged commit c093421 into google:develop Mar 9, 2023
@@ -166,6 +166,9 @@ Blockly.Msg.VARIABLE_ALREADY_EXISTS = 'A variable named "%1" already exists.';
/** @type {string} */
/// alert - Tells the user that the name they entered is already in use for another type.
Blockly.Msg.VARIABLE_ALREADY_EXISTS_FOR_ANOTHER_TYPE = 'A variable named "%1" already exists for another type: "%2".';
/** @type {string} */
/// alert - Tells the user that the name they entered is already in use as a parameter to a procedure, that the variable they are renaming also exists on. Renaming would create two parameters with the same name, which is not allowed.
Blockly.Msg.VARIABLE_ALREADY_EXISTS_FOR_A_PARAMETER = 'A variable named "%1" already exists as a parameter in the procedure "%2".';
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you did not npm run messages (formerly …generate:langfiles), so this message is not included in any translation (including English).

@cpcallen cpcallen mentioned this pull request Jun 28, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Renaming vars so that you get duplicate procedure vars breaks mutator (sometimes)
4 participants