diff --git a/artiq/compiler/module.py b/artiq/compiler/module.py index 052a176ac..c19d6d0ac 100644 --- a/artiq/compiler/module.py +++ b/artiq/compiler/module.py @@ -64,8 +64,8 @@ class Module: interleaver = transforms.Interleaver(engine=self.engine) invariant_detection = analyses.InvariantDetection(engine=self.engine) - cast_monomorphizer.visit(src.typedtree) int_monomorphizer.visit(src.typedtree) + cast_monomorphizer.visit(src.typedtree) inferencer.visit(src.typedtree) monomorphism_validator.visit(src.typedtree) escape_validator.visit(src.typedtree) diff --git a/artiq/compiler/transforms/cast_monomorphizer.py b/artiq/compiler/transforms/cast_monomorphizer.py index 50e2bda4f..8e373ab1e 100644 --- a/artiq/compiler/transforms/cast_monomorphizer.py +++ b/artiq/compiler/transforms/cast_monomorphizer.py @@ -18,6 +18,7 @@ class CastMonomorphizer(algorithm.Visitor): types.is_builtin(node.func.type, "int64")): typ = node.type.find() if (not types.is_var(typ["width"]) and + len(node.args) == 1 and builtins.is_int(node.args[0].type) and types.is_var(node.args[0].type.find()["width"])): if isinstance(node.args[0], asttyped.BinOpT): diff --git a/artiq/test/lit/monomorphism/bug_1242.py b/artiq/test/lit/monomorphism/bug_1242.py new file mode 100644 index 000000000..8918a30cc --- /dev/null +++ b/artiq/test/lit/monomorphism/bug_1242.py @@ -0,0 +1,8 @@ +# RUN: %python -m artiq.compiler.testbench.signature %s >%t +# RUN: OutputCheck %s --file-to-check=%t + +x = 0x100000000 +# CHECK-L: x: numpy.int64 + +y = int32(x) +# CHECK-L: y: numpy.int32