From 4d915ad15beddca5aa8ef6ff741379bbbb37c962 Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 27 Dec 2017 01:52:27 +0000 Subject: [PATCH] compiler: do not permit str(...). (#878) --- artiq/compiler/transforms/inferencer.py | 5 +++++ artiq/test/lit/inferencer/error_builtin_calls.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/artiq/compiler/transforms/inferencer.py b/artiq/compiler/transforms/inferencer.py index c4fb07b94..5c54f235c 100644 --- a/artiq/compiler/transforms/inferencer.py +++ b/artiq/compiler/transforms/inferencer.py @@ -682,6 +682,11 @@ class Inferencer(algorithm.Visitor): pass else: diagnose(valid_forms()) + elif types.is_builtin(typ, "str"): + diag = diagnostic.Diagnostic("error", + "strings currently cannot be constructed", {}, + node.loc) + self.engine.process(diag) elif types.is_builtin(typ, "list") or types.is_builtin(typ, "array"): if types.is_builtin(typ, "list"): valid_forms = lambda: [ diff --git a/artiq/test/lit/inferencer/error_builtin_calls.py b/artiq/test/lit/inferencer/error_builtin_calls.py index f3d8b7df8..bb1b8ca04 100644 --- a/artiq/test/lit/inferencer/error_builtin_calls.py +++ b/artiq/test/lit/inferencer/error_builtin_calls.py @@ -9,3 +9,6 @@ list(1) # CHECK-L: ${LINE:+1}: error: the arguments of min() must be of a numeric type min([1], [1]) + +# CHECK-L: ${LINE:+1}: error: strings currently cannot be constructed +str(1)