mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
shader: Bug fix ++/-- must not be applied to a blank identifier
This commit is contained in:
parent
3421598e64
commit
fd51abfb0d
@ -346,7 +346,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
|
|||||||
})
|
})
|
||||||
|
|
||||||
case *ast.IncDecStmt:
|
case *ast.IncDecStmt:
|
||||||
exprs, _, ss, ok := cs.parseExpr(block, stmt.X, false)
|
exprs, _, ss, ok := cs.parseExpr(block, stmt.X, true)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
return vec4(0)
|
return vec4(0)
|
||||||
}
|
}
|
||||||
`)); err != nil {
|
`)); err != nil {
|
||||||
t.Errorf("error must be nil but non-nil: %v", err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := NewShader([]byte(`package main
|
if _, err := NewShader([]byte(`package main
|
||||||
@ -236,7 +236,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
return vec4(0)
|
return vec4(0)
|
||||||
}
|
}
|
||||||
`)); err != nil {
|
`)); err != nil {
|
||||||
t.Errorf("error must be nil but non-nil: %v", err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,6 +576,8 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
t.Errorf("error must be non-nil but was nil")
|
t.Errorf("error must be non-nil but was nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Increment statement treats a variable 'used'.
|
||||||
|
// https://play.golang.org/p/2RuYMrSLjt3
|
||||||
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 {
|
||||||
@ -583,8 +585,8 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
x++
|
x++
|
||||||
return vec4(0)
|
return vec4(0)
|
||||||
}
|
}
|
||||||
`)); err == nil {
|
`)); err != nil {
|
||||||
t.Errorf("error must be non-nil but was nil")
|
t.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -630,6 +632,16 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
_ = x
|
_ = x
|
||||||
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 {
|
||||||
|
_++
|
||||||
|
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