-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
BugThis tag is applied to issues which reports bugs.This tag is applied to issues which reports bugs.
Description
Describe the bug
v fmt reports duplicate method error when the same method is defined in mutually exclusive $if/$else or $if flag ?/$if !flag ? blocks. The code compiles and runs correctly, but cannot be formatted.
Reproduction Steps
module main
$if foo ? {
pub fn (x int) str() string {
return 'foo mode'
}
} $else {
pub fn (x int) str() string {
return 'normal mode'
}
}
fn main() {
println(42.str())
}Steps to reproduce:
v run test.v # works
v -d foo run test.v # works
v fmt test.v # failsExpected Behavior
v fmt should recognize mutually exclusive $if blocks and not report duplicate methods
Current Behavior
test.v:10:16: error: duplicate method `str`
8 | } $else {
9 |
10 | pub fn (x int) str() string {
| ~~~
11 | return 'normal mode'
12 | }Possible Solution
No response
Additional Information/Context
Impact: Cannot format files which use this pattern for conditional compilation.
V version
V 0.5.0 e3616f2
Environment details (OS name and version, etc.)
V full version: V 0.5.0 9a73766.e3616f2
OS: Linux
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.
Avey777 and enghitalo
Metadata
Metadata
Assignees
Labels
BugThis tag is applied to issues which reports bugs.This tag is applied to issues which reports bugs.