-
Notifications
You must be signed in to change notification settings - Fork 398
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
blank identifier "_" should not be used as value or type #1946
Comments
7 tasks
7 tasks
7 tasks
ltzmaxwell
pushed a commit
that referenced
this issue
Nov 27, 2024
# Description Closes #1946 The `isNamedConversion` function now includes a safety check to prevent the use of blank identifiers ("_") as values or types. If both `xt` and `t` are nil, the function assumes that a blank identifier is being used inappropriately and panics with an error message that includes the location of the issue. ## Variable Explanations - `xt` (Expression Type): Represents the type of the right-hand side of an assignment or expression. It's the type resulting from evaluating an expression. - `t` (Target Type): Represents the type of the left-hand side of an assignment. It's the variable or field that will receive the value. Checks if a named conversion is needed when assigning a value of type `xt` to a variable of type `t`. ## Preprocess Added some checks to prevent the disallowd usage of blank identifiers in `Preprocess` function level. Theses checks are performed at different stages of the preprocessing: 1. `TRANS_ENTER` for `AssignStmt`: - Checks if both LHS and RHS are blank identifiers in a `DEFINE` statement. 2. `TRANS_LEAVE` for `NameExpr`: - Checks if blank identifier is used as a value in disallowed contexts (excluding `TRANS_ASSIGN_LHS`, `TRANS_RANGE_KEY` and `TRANS_RANGE_VALUE`). 3. `TRANS_LEAVE` for `AssignStmt`: - Checks if RHS is a blank identifier when LHS is not, in a `DEFINE` statement. When any of these conditions are met, the function throws an panics like go message. <!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [X] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [X] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Co-authored-by: Morgan <morgan@morganbaz.com>
r3v4s
pushed a commit
to gnoswap-labs/gno
that referenced
this issue
Dec 10, 2024
…#2699) # Description Closes gnolang#1946 The `isNamedConversion` function now includes a safety check to prevent the use of blank identifiers ("_") as values or types. If both `xt` and `t` are nil, the function assumes that a blank identifier is being used inappropriately and panics with an error message that includes the location of the issue. ## Variable Explanations - `xt` (Expression Type): Represents the type of the right-hand side of an assignment or expression. It's the type resulting from evaluating an expression. - `t` (Target Type): Represents the type of the left-hand side of an assignment. It's the variable or field that will receive the value. Checks if a named conversion is needed when assigning a value of type `xt` to a variable of type `t`. ## Preprocess Added some checks to prevent the disallowd usage of blank identifiers in `Preprocess` function level. Theses checks are performed at different stages of the preprocessing: 1. `TRANS_ENTER` for `AssignStmt`: - Checks if both LHS and RHS are blank identifiers in a `DEFINE` statement. 2. `TRANS_LEAVE` for `NameExpr`: - Checks if blank identifier is used as a value in disallowed contexts (excluding `TRANS_ASSIGN_LHS`, `TRANS_RANGE_KEY` and `TRANS_RANGE_VALUE`). 3. `TRANS_LEAVE` for `AssignStmt`: - Checks if RHS is a blank identifier when LHS is not, in a `DEFINE` statement. When any of these conditions are met, the function throws an panics like go message. <!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [X] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [X] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Co-authored-by: Morgan <morgan@morganbaz.com>
albttx
pushed a commit
that referenced
this issue
Jan 10, 2025
# Description Closes #1946 The `isNamedConversion` function now includes a safety check to prevent the use of blank identifiers ("_") as values or types. If both `xt` and `t` are nil, the function assumes that a blank identifier is being used inappropriately and panics with an error message that includes the location of the issue. ## Variable Explanations - `xt` (Expression Type): Represents the type of the right-hand side of an assignment or expression. It's the type resulting from evaluating an expression. - `t` (Target Type): Represents the type of the left-hand side of an assignment. It's the variable or field that will receive the value. Checks if a named conversion is needed when assigning a value of type `xt` to a variable of type `t`. ## Preprocess Added some checks to prevent the disallowd usage of blank identifiers in `Preprocess` function level. Theses checks are performed at different stages of the preprocessing: 1. `TRANS_ENTER` for `AssignStmt`: - Checks if both LHS and RHS are blank identifiers in a `DEFINE` statement. 2. `TRANS_LEAVE` for `NameExpr`: - Checks if blank identifier is used as a value in disallowed contexts (excluding `TRANS_ASSIGN_LHS`, `TRANS_RANGE_KEY` and `TRANS_RANGE_VALUE`). 3. `TRANS_LEAVE` for `AssignStmt`: - Checks if RHS is a blank identifier when LHS is not, in a `DEFINE` statement. When any of these conditions are met, the function throws an panics like go message. <!-- please provide a detailed description of the changes made in this pull request. --> <details><summary>Contributors' checklist...</summary> - [X] Added new tests, or not needed, or not feasible - [ ] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [ ] Updated the official documentation or not needed - [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [X] Added references to related issues and PRs - [ ] Provided any useful hints for running manual tests - [ ] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Co-authored-by: Morgan <morgan@morganbaz.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this should fail in Gno but not:
The text was updated successfully, but these errors were encountered: