-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interp: detect local redeclaration (#673)
* interp: detect local redecleration Fixes #666 * make make check happy * fix typo in filenames, add them to the exclusion list Co-authored-by: Marc Vertes <mvertes@free.fr>
- Loading branch information
Showing
8 changed files
with
127 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
func main() { | ||
type foo struct { | ||
yolo string | ||
} | ||
|
||
var foo int | ||
foo = 2 | ||
println(foo) | ||
} | ||
|
||
// Error: | ||
// ../_test/redeclaration0.go:8:6: foo redeclared in this block | ||
// previous declaration at ../_test/redeclaration0.go:4:7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package main | ||
|
||
func main() { | ||
var foo string | ||
|
||
var foo int | ||
foo = 2 | ||
println(foo) | ||
} | ||
|
||
// Error: | ||
// ../_test/redeclaration1.go:6:6: foo redeclared in this block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package main | ||
|
||
func main() { | ||
var foo struct { | ||
yolo string | ||
} | ||
|
||
var foo int | ||
foo = 2 | ||
println(foo) | ||
} | ||
|
||
// Error: | ||
// ../_test/redeclaration2.go:8:6: foo redeclared in this block | ||
// previous declaration at ../_test/redeclaration2.go:4:6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package main | ||
|
||
func main() { | ||
var foo int | ||
foo = 2 | ||
|
||
type foo struct{} | ||
var bar foo | ||
println(bar) | ||
} | ||
|
||
// Error: | ||
// ../_test/redeclaration3.go:7:7: foo redeclared in this block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
func main() { | ||
var foo struct{ | ||
yolo string | ||
} | ||
|
||
type foo struct{} | ||
var bar foo | ||
println(bar) | ||
} | ||
|
||
// Error: | ||
// ../_test/redeclaration4.go:8:7: foo redeclared in this block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package main | ||
|
||
func main() { | ||
type foo struct{ | ||
yolo string | ||
} | ||
|
||
type foo struct{} | ||
var bar foo | ||
println(bar) | ||
} | ||
|
||
// Error: | ||
// ../_test/redeclaration5.go:8:7: foo redeclared in this block |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters