shader: Bug fix: a blank identifier lhs and += cannot work

This commit is contained in:
Hajime Hoshi 2020-09-14 00:51:27 +09:00
parent fd51abfb0d
commit e1d8629189
2 changed files with 11 additions and 1 deletions

View File

@ -81,7 +81,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
}
stmts = append(stmts, ss...)
lhs, ts, ss, ok := cs.parseExpr(block, stmt.Lhs[0], false)
lhs, ts, ss, ok := cs.parseExpr(block, stmt.Lhs[0], true)
if !ok {
return nil, false
}

View File

@ -642,6 +642,16 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
_++
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 {
_ += 1
return vec4(0)
}
`)); err == nil {
t.Errorf("error must be non-nil but was nil")
}