-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Failed to compile the assert expression with the sub expression -(-2) or +2Β #26815
Copy link
Copy link
Open
Labels
BugThis tag is applied to issues which reports bugs.This tag is applied to issues which reports bugs.
Description
Describe the bug
In the expression assert, failed to compile those simple math sub expressions such as -(-2) , +2.
Reproduction Steps
the test
testfiles> v conv_test.v
conv_test.v:8:33: error: invalid expression: unexpected token `==`
6 | assert strconv.atoi('-2')! == -2
7 | assert strconv.atoi('+2')! == i - 1 + 1
8 | assert strconv.atoi('+2')! == -(-2)
| ^
9 | assert strconv.atoi('+2')! == +2
10 | }
testfiles> v conv_test.v
conv_test.v:9:33: error: invalid expression: unexpected token `+`
7 | assert strconv.atoi('+2')! == i - 1 + 1
8 | //assert strconv.atoi('+2')! == -(-2)
9 | assert strconv.atoi('+2')! == +2
| ^
10 | }
testfiles>the test source
import strconv
fn test_atoi() ! {
i := 2
assert strconv.atoi('1')! == 1
assert strconv.atoi('-2')! == -2
assert strconv.atoi('+2')! == i - 1 + 1
assert strconv.atoi('+2')! == -(-2)
assert strconv.atoi('+2')! == +2
}Expected Behavior
Compiling ok.
Current Behavior
Failed to compile it.
Possible Solution
No response
Additional Information/Context
No response
V version
V 0.5.1 0c3183c
Environment details (OS name and version, etc.)
Windows 10 amd64.
Note
You can use the π reaction to increase the issue's priority for developers.
Please note that only the π reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugThis tag is applied to issues which reports bugs.This tag is applied to issues which reports bugs.