Skip to content
Snippets Groups Projects
Commit 2b8884d9 authored by Daniel Bauer's avatar Daniel Bauer :speech_balloon:
Browse files

test freeze of cast of bare constant and failing type inference

parent d1a9c0ef
Branches
No related merge requests found
Pipeline #68001 passed with stages
in 2 minutes and 52 seconds
...@@ -29,6 +29,7 @@ from pystencils.backend.ast.expressions import ( ...@@ -29,6 +29,7 @@ from pystencils.backend.ast.expressions import (
PsGe, PsGe,
PsCall, PsCall,
PsCast, PsCast,
PsConstantExpr,
) )
from pystencils.backend.constants import PsConstant from pystencils.backend.constants import PsConstant
from pystencils.backend.functions import PsMathFunction, MathFunctions from pystencils.backend.functions import PsMathFunction, MathFunctions
...@@ -286,3 +287,6 @@ def test_cast_func(): ...@@ -286,3 +287,6 @@ def test_cast_func():
expr = freeze(CastFunc.as_index(z)) expr = freeze(CastFunc.as_index(z))
assert expr.structurally_equal(PsCast(ctx.index_dtype, z2)) assert expr.structurally_equal(PsCast(ctx.index_dtype, z2))
expr = freeze(CastFunc(42, create_type("int16")))
assert expr.structurally_equal(PsConstantExpr(PsConstant(42, create_type("int16"))))
...@@ -14,6 +14,9 @@ from pystencils.backend.ast.structural import ( ...@@ -14,6 +14,9 @@ from pystencils.backend.ast.structural import (
PsBlock, PsBlock,
) )
from pystencils.backend.ast.expressions import ( from pystencils.backend.ast.expressions import (
PsAddressOf,
PsArrayInitList,
PsCast,
PsConstantExpr, PsConstantExpr,
PsSymbolExpr, PsSymbolExpr,
PsSubscript, PsSubscript,
...@@ -478,3 +481,19 @@ def test_cfunction(): ...@@ -478,3 +481,19 @@ def test_cfunction():
with pytest.raises(TypificationError): with pytest.raises(TypificationError):
_ = typify(PsCall(threeway, (x, p))) _ = typify(PsCall(threeway, (x, p)))
def test_inference_fails():
ctx = KernelCreationContext()
typify = Typifier(ctx)
x = PsExpression.make(PsConstant(42))
with pytest.raises(TypificationError):
typify(PsEq(x, x))
with pytest.raises(TypificationError):
typify(PsArrayInitList([x]))
with pytest.raises(TypificationError):
typify(PsCast(ctx.default_dtype, x))
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment