mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
shader: Bug fix: Ignore blank identifiers for the duplication check
Fixes #1330
This commit is contained in:
parent
4ac11bf156
commit
55f0c983ba
@ -470,10 +470,12 @@ func (cs *compileState) assign(block *block, pos token.Pos, lhs, rhs []ast.Expr,
|
||||
|
||||
if define {
|
||||
name := e.(*ast.Ident).Name
|
||||
for _, v := range block.vars {
|
||||
if v.name == name {
|
||||
cs.addError(pos, fmt.Sprintf("duplicated local variable name: %s", name))
|
||||
return nil, false
|
||||
if name != "_" {
|
||||
for _, v := range block.vars {
|
||||
if v.name == name {
|
||||
cs.addError(pos, fmt.Sprintf("duplicated local variable name: %s", name))
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
}
|
||||
ts, ok := cs.functionReturnTypes(block, rhs[i])
|
||||
@ -573,10 +575,12 @@ func (cs *compileState) assign(block *block, pos token.Pos, lhs, rhs []ast.Expr,
|
||||
|
||||
if define {
|
||||
name := e.(*ast.Ident).Name
|
||||
for _, v := range block.vars {
|
||||
if v.name == name {
|
||||
cs.addError(pos, fmt.Sprintf("duplicated local variable name: %s", name))
|
||||
return nil, false
|
||||
if name != "_" {
|
||||
for _, v := range block.vars {
|
||||
if v.name == name {
|
||||
cs.addError(pos, fmt.Sprintf("duplicated local variable name: %s", name))
|
||||
return nil, false
|
||||
}
|
||||
}
|
||||
}
|
||||
v := variable{
|
||||
|
26
internal/shader/testdata/blank.expected.vs
vendored
Normal file
26
internal/shader/testdata/blank.expected.vs
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
void F0(out int l0, out int l1);
|
||||
void F1(void);
|
||||
|
||||
void F0(out int l0, out int l1) {
|
||||
l0 = 1;
|
||||
l1 = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
void F1(void) {
|
||||
int l0 = 0;
|
||||
int l1 = 0;
|
||||
int l2 = 0;
|
||||
int l3 = 0;
|
||||
int l4 = 0;
|
||||
int l5 = 0;
|
||||
int l6 = 0;
|
||||
int l7 = 0;
|
||||
int l8 = 0;
|
||||
int l9 = 0;
|
||||
F0(l0, l1);
|
||||
F0(l2, l3);
|
||||
l4 = l2;
|
||||
F0(l6, l7);
|
||||
l9 = l7;
|
||||
}
|
11
internal/shader/testdata/blank.go
vendored
Normal file
11
internal/shader/testdata/blank.go
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
func Foo() (int, int) {
|
||||
return 1, 1
|
||||
}
|
||||
|
||||
func Bar() {
|
||||
_, _ = Foo()
|
||||
a, _ := Foo()
|
||||
_, b := Foo()
|
||||
}
|
Loading…
Reference in New Issue
Block a user