forked from traefik/yaegi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interp: fix parsing of late binding consts
When a const is late binding and specified with a type, the GTA defineStmt was creating the symbol with the current scopes `iota` which is incorrect. The symbol should be created with the source nodes `rval`. Related to traefik#1158
- Loading branch information
1 parent
9e99404
commit 1c7e3ca
Showing
2 changed files
with
29 additions
and
2 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,28 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func init() { | ||
fmt.Println(constString) | ||
fmt.Println(const2) | ||
fmt.Println(varString) | ||
} | ||
|
||
const constString string = "hello" | ||
|
||
const ( | ||
const1 = iota + 10 | ||
const2 | ||
const3 | ||
) | ||
|
||
var varString string = "test" | ||
|
||
func main() {} | ||
|
||
// Output: | ||
// hello | ||
// 11 | ||
// test |
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