mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-23 17:32:02 +01:00
shader: Bug fix: selector is not available on a blank identifier
This commit is contained in:
parent
e1d8629189
commit
ded223ead0
@ -437,7 +437,7 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr, markLocalVariable
|
|||||||
return cs.parseExpr(block, e.X, markLocalVariableUsed)
|
return cs.parseExpr(block, e.X, markLocalVariableUsed)
|
||||||
|
|
||||||
case *ast.SelectorExpr:
|
case *ast.SelectorExpr:
|
||||||
exprs, _, stmts, ok := cs.parseExpr(block, e.X, markLocalVariableUsed)
|
exprs, _, stmts, ok := cs.parseExpr(block, e.X, true)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil, nil, false
|
return nil, nil, nil, false
|
||||||
}
|
}
|
||||||
|
@ -572,8 +572,8 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
x.x = 1
|
x.x = 1
|
||||||
return vec4(0)
|
return vec4(0)
|
||||||
}
|
}
|
||||||
`)); err == nil {
|
`)); err != nil {
|
||||||
t.Errorf("error must be non-nil but was nil")
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increment statement treats a variable 'used'.
|
// Increment statement treats a variable 'used'.
|
||||||
@ -590,7 +590,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestShaderBlankRhs(t *testing.T) {
|
func TestShaderBlankLhs(t *testing.T) {
|
||||||
if _, err := NewShader([]byte(`package main
|
if _, err := NewShader([]byte(`package main
|
||||||
|
|
||||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
@ -652,6 +652,16 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
_ += 1
|
_ += 1
|
||||||
return vec4(0)
|
return vec4(0)
|
||||||
}
|
}
|
||||||
|
`)); err == nil {
|
||||||
|
t.Errorf("error must be non-nil but was nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := NewShader([]byte(`package main
|
||||||
|
|
||||||
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
|
_.x = 1
|
||||||
|
return vec4(0)
|
||||||
|
}
|
||||||
`)); err == nil {
|
`)); err == nil {
|
||||||
t.Errorf("error must be non-nil but was nil")
|
t.Errorf("error must be non-nil but was nil")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user