artiq/artiq/compiler
Jonathan Coates cc81464f53 Fix type annotations with mixed tuples
The type checker/inferer visits every node in an AST tree, including
function return annotations. This means for a function definition like

    def f() -> TTuple([TInt32, TBool]):
      ...

We attempt to type check the list [TInt32, TBool], which generates the
unification constraint builtins.TBool ~ builtins.TInt. This causes an
internal error due to compiler weirdness.

We can avoid this by just nulling-out the return annotation in the
embedding stage. The return type isn't actually used anywhere (it's
extracted via the inspect module instead), so this is entirely safe.

Arguments aren't affected by this, as we already nulled out the
annotation (see visit_arg in embedding.py).

Signed-off-by: Jonathan Coates <jonathan.coates@oxionics.com>
2023-09-27 10:27:05 +08:00
..
algorithms compiler: do not associate SSA values with iodelay even when inlining. 2015-12-25 15:02:33 +08:00
analyses compiler: Constness is a validator, not analysis. 2017-06-09 07:29:31 +00:00
testbench compiler/tb: use FPU 2021-11-08 16:59:08 +08:00
transforms compiler: Extract maximum alignment from target data layout 2022-11-15 11:06:38 +08:00
validators compiler: T{C -> External}Function, clarify docs [nfc] 2020-08-09 03:54:41 +01:00
__init__.py compiler: pull in dependencies in more finely grained way (fixes #181). 2015-11-24 17:32:04 +08:00
asttyped.py compiler: allow specifying per-function "fast-math" flags. 2016-03-28 21:44:08 +00:00
builtins.py compiler: Fix #1871 (array() breaks math functions) 2022-04-22 00:12:20 +01:00
embedding.py Fix type annotations with mixed tuples 2023-09-27 10:27:05 +08:00
import_cache.py import_cache: make sure last line ends with \n as linecache does. Closes #547 2016-09-02 11:01:28 +08:00
iodelay.py compiler.iodelay: correctly fold max(0, [0, ]...). 2015-11-24 00:46:55 +08:00
ir.py compiler: fixed dead code eliminator 2022-01-26 07:16:54 +08:00
kernel.ld compiler: Add missing sections to kernel linker script 2022-11-25 09:50:18 +08:00
math_fns.py compiler: Provide libm special functions (erf, Bessel functions, …) 2020-11-11 19:15:30 +01:00
module.py test: fixed lit tests 2022-01-26 07:16:54 +08:00
prelude.py compiler: remove obsolete watchdog code (#1458) 2020-12-08 13:25:08 +08:00
targets.py compiler/targets: Fix refactoring leftover for native (host) target 2022-11-15 11:06:06 +08:00
types.py syscall: lower nowrite to inaccessiblememonly 2021-09-10 13:25:12 +08:00