From a9a975e5d4aec6e88c2feff94d6cce80c46e72fa Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Mon, 27 Jul 2020 23:36:42 +0100 Subject: [PATCH] language: Allow instantating TArray using bare ints --- artiq/compiler/builtins.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/artiq/compiler/builtins.py b/artiq/compiler/builtins.py index af0201765..7edd97d9a 100644 --- a/artiq/compiler/builtins.py +++ b/artiq/compiler/builtins.py @@ -82,9 +82,12 @@ class TList(types.TMono): super().__init__("list", {"elt": elt}) class TArray(types.TMono): - def __init__(self, elt=None, num_dims=types.TValue(1)): + def __init__(self, elt=None, num_dims=1): if elt is None: elt = types.TVar() + if isinstance(num_dims, int): + # Make TArray more convenient to instantiate from (ARTIQ) user code. + num_dims = types.TValue(num_dims) # For now, enforce number of dimensions to be known, as we'd otherwise # need to implement custom unification logic for the type of `shape`. # Default to 1 to keep compatibility with old user code from before