mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
internal/shader: Bug fix: Treat a non-typed consntat argument as a float
Closes #1874
This commit is contained in:
parent
97af84c32a
commit
960b3796b2
@ -200,6 +200,13 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr, markLocalVariable
|
||||
cs.addError(e.Pos(), fmt.Sprintf("single-value context and multiple-value context cannot be mixed: %s", e.Fun))
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
// If the argument is a non-typed constant value, treat is as a float value (#1874).
|
||||
for i, e := range es {
|
||||
if e.Type == shaderir.NumberExpr && e.ConstType == shaderir.ConstTypeNone {
|
||||
e.ConstType = shaderir.ConstTypeFloat
|
||||
ts[i] = shaderir.Type{Main: shaderir.Float}
|
||||
}
|
||||
}
|
||||
args = append(args, es...)
|
||||
argts = append(argts, ts...)
|
||||
stmts = append(stmts, ss...)
|
||||
|
6
internal/shader/testdata/issue1874.expected.vs
vendored
Normal file
6
internal/shader/testdata/issue1874.expected.vs
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
void F0(out float l0);
|
||||
|
||||
void F0(out float l0) {
|
||||
l0 = (sin(1.0000000000e-01)) + (cos(2.0000000000e-01));
|
||||
return;
|
||||
}
|
9
internal/shader/testdata/issue1874.go
vendored
Normal file
9
internal/shader/testdata/issue1874.go
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
func Foo() float {
|
||||
const (
|
||||
s = 0.1
|
||||
c = 0.2
|
||||
)
|
||||
return sin(s) + cos(c)
|
||||
}
|
Loading…
Reference in New Issue
Block a user