mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-02-04 15:04:28 +01:00
internal/shader: bug fix: forbid to have an initial value for uniform variables
Closes #2711
This commit is contained in:
parent
1b8580fab7
commit
4df647a400
@ -395,6 +395,11 @@ func (cs *compileState) parseDecl(b *block, fname string, d ast.Decl) ([]shaderi
|
|||||||
|
|
||||||
stmts = append(stmts, ss...)
|
stmts = append(stmts, ss...)
|
||||||
if b == &cs.global {
|
if b == &cs.global {
|
||||||
|
if len(inits) > 0 {
|
||||||
|
cs.addError(s.Pos(), "a uniform variable cannot have initial values")
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Should rhs be ignored?
|
// TODO: Should rhs be ignored?
|
||||||
for i, v := range vs {
|
for i, v := range vs {
|
||||||
if !strings.HasPrefix(v.name, "__") {
|
if !strings.HasPrefix(v.name, "__") {
|
||||||
|
@ -3260,6 +3260,20 @@ func foo(x vec2) {
|
|||||||
}`)); err == nil {
|
}`)); err == nil {
|
||||||
t.Error("compileToIR must return an error but did not")
|
t.Error("compileToIR must return an error but did not")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue #2711
|
||||||
|
if _, err := compileToIR([]byte(`package main
|
||||||
|
|
||||||
|
var Foo float = 1
|
||||||
|
`)); err == nil {
|
||||||
|
t.Error("compileToIR must return an error but did not")
|
||||||
|
}
|
||||||
|
if _, err := compileToIR([]byte(`package main
|
||||||
|
|
||||||
|
var Foo, Bar int = 1, 1
|
||||||
|
`)); err == nil {
|
||||||
|
t.Error("compileToIR must return an error but did not")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue #2705
|
// Issue #2705
|
||||||
|
Loading…
Reference in New Issue
Block a user