guppylang-internals 0.25.0__tar.gz → 0.26.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. guppylang_internals-0.26.0/CHANGELOG.md +161 -0
  2. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/PKG-INFO +4 -3
  3. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/README.md +2 -2
  4. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/pyproject.toml +2 -1
  5. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/__init__.py +1 -1
  6. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/cfg/builder.py +17 -2
  7. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/cfg/cfg.py +3 -0
  8. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/cfg_checker.py +6 -0
  9. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/core.py +1 -2
  10. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/errors/wasm.py +7 -4
  11. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/expr_checker.py +13 -8
  12. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/func_checker.py +17 -13
  13. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/linearity_checker.py +2 -10
  14. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/modifier_checker.py +6 -2
  15. guppylang_internals-0.26.0/src/guppylang_internals/checker/unitary_checker.py +132 -0
  16. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/cfg_compiler.py +7 -6
  17. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/core.py +5 -5
  18. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/expr_compiler.py +42 -73
  19. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/modifier_compiler.py +2 -0
  20. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/decorator.py +86 -7
  21. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/custom.py +4 -0
  22. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/declaration.py +6 -2
  23. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/function.py +12 -2
  24. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/pytket_circuits.py +1 -0
  25. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/struct.py +6 -3
  26. guppylang_internals-0.26.0/src/guppylang_internals/definition/wasm.py +93 -0
  27. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/engine.py +9 -3
  28. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/nodes.py +23 -24
  29. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/checker.py +13 -108
  30. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/array.py +1 -1
  31. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/list.py +1 -1
  32. guppylang_internals-0.26.0/src/guppylang_internals/std/_internal/compiler/platform.py +153 -0
  33. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/prelude.py +12 -4
  34. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/tket_exts.py +3 -4
  35. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/debug.py +18 -9
  36. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/util.py +1 -1
  37. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/object.py +10 -0
  38. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/errors.py +23 -1
  39. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/parsing.py +3 -3
  40. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/printing.py +2 -8
  41. guppylang_internals-0.26.0/src/guppylang_internals/tys/qubit.py +62 -0
  42. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/ty.py +60 -64
  43. guppylang_internals-0.26.0/src/guppylang_internals/wasm_util.py +129 -0
  44. guppylang_internals-0.25.0/CHANGELOG.md +0 -123
  45. guppylang_internals-0.25.0/src/guppylang_internals/definition/wasm.py +0 -61
  46. guppylang_internals-0.25.0/src/guppylang_internals/tys/qubit.py +0 -27
  47. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/.gitignore +0 -0
  48. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/LICENCE +0 -0
  49. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/ast_util.py +0 -0
  50. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/cfg/__init__.py +0 -0
  51. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/cfg/analysis.py +0 -0
  52. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/cfg/bb.py +0 -0
  53. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/__init__.py +0 -0
  54. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/errors/__init__.py +0 -0
  55. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/errors/comptime_errors.py +0 -0
  56. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/errors/generic.py +0 -0
  57. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/errors/linearity.py +0 -0
  58. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/errors/type_errors.py +0 -0
  59. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/stmt_checker.py +0 -0
  60. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/__init__.py +0 -0
  61. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/func_compiler.py +0 -0
  62. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/hugr_extension.py +0 -0
  63. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/qtm_platform_extension.py +0 -0
  64. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/stmt_compiler.py +0 -0
  65. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/__init__.py +0 -0
  66. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/common.py +0 -0
  67. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/const.py +0 -0
  68. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/extern.py +0 -0
  69. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/overloaded.py +0 -0
  70. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/parameter.py +0 -0
  71. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/traced.py +0 -0
  72. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/ty.py +0 -0
  73. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/value.py +0 -0
  74. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/diagnostic.py +0 -0
  75. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/dummy_decorator.py +0 -0
  76. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/error.py +0 -0
  77. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/experimental.py +0 -0
  78. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/ipython_inspect.py +0 -0
  79. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/py.typed +0 -0
  80. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/span.py +0 -0
  81. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/__init__.py +0 -0
  82. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/__init__.py +0 -0
  83. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/__init__.py +0 -0
  84. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/arithmetic.py +0 -0
  85. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/either.py +0 -0
  86. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/frozenarray.py +0 -0
  87. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/futures.py +0 -0
  88. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/mem.py +0 -0
  89. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/option.py +0 -0
  90. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/qsystem.py +0 -0
  91. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/quantum.py +0 -0
  92. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/tket_bool.py +0 -0
  93. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/wasm.py +0 -0
  94. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler.py +0 -0
  95. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/__init__.py +0 -0
  96. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/builtins_mock.py +0 -0
  97. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/frozenlist.py +0 -0
  98. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/function.py +0 -0
  99. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/state.py +0 -0
  100. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/unpacking.py +0 -0
  101. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/util.py +0 -0
  102. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/__init__.py +0 -0
  103. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/arg.py +0 -0
  104. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/builtin.py +0 -0
  105. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/common.py +0 -0
  106. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/const.py +0 -0
  107. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/param.py +0 -0
  108. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/subst.py +0 -0
  109. {guppylang_internals-0.25.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/var.py +0 -0
@@ -0,0 +1,161 @@
1
+ # Changelog
2
+
3
+ First release of `guppylang_internals` package containing refactored out internal components
4
+ from `guppylang`.
5
+
6
+ ## [0.26.0](https://github.com/Quantinuum/guppylang/compare/guppylang-internals-v0.25.0...guppylang-internals-v0.26.0) (2025-12-11)
7
+
8
+
9
+ ### ⚠ BREAKING CHANGES
10
+
11
+ * `FunctionType` constructor no longer accepts the `input_names` argument. Instead, input names should be provided as an optional argument to `FuncInput`
12
+ * Removed `guppylang_internals.nodes.ResultExpr` Moved `guppylang_internals.std._internal.checker.{TAG_MAX_LEN, TooLongError}` to `guppylang_internals.std._internal.compiler.platform`
13
+ *
14
+ * The `tag` field of `guppylang_internals.nodes.{ResultExpr, StateResultExpr}` has been replaced with a const `tag_value` and a `tag_expr` expression
15
+ * `guppylang_internals.tys.ty.SumType` has been removed
16
+ *
17
+ * `modifier_checker.check_modified_block_signature` now requires the `ModifiedBlock` as first argument
18
+
19
+ ### Features
20
+
21
+ * Allow dynamic tag and signal in `panic`/`exit` ([#1327](https://github.com/Quantinuum/guppylang/issues/1327)) ([bae0da1](https://github.com/Quantinuum/guppylang/commit/bae0da1d42eea88d34c5c7bdd3d7f8a2504f1501))
22
+ * Unitarity annotations for functions ([#1292](https://github.com/Quantinuum/guppylang/issues/1292)) ([54dc200](https://github.com/Quantinuum/guppylang/commit/54dc200de881d065d3ee92bdc9a8ca076990d412))
23
+ * Validate signatures against wasm file ([#1339](https://github.com/Quantinuum/guppylang/issues/1339)) ([e57059b](https://github.com/Quantinuum/guppylang/commit/e57059b0ed61e6d76492e52d2a6f8c83f421e46b))
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * Allow comptime string arguments as result tags ([#1354](https://github.com/Quantinuum/guppylang/issues/1354)) ([cdc5c68](https://github.com/Quantinuum/guppylang/commit/cdc5c680879ae160bb592212cc8ed2fe6fc9ddbe))
29
+ * Fix calls with comptime args inside comptime functions ([#1360](https://github.com/Quantinuum/guppylang/issues/1360)) ([8321303](https://github.com/Quantinuum/guppylang/commit/83213034a3c74e158bb58bbd1ff34ab7d253d981)), closes [#1359](https://github.com/Quantinuum/guppylang/issues/1359)
30
+ * Fix internal compiler error when returning generic functions as values in comptime ([#1337](https://github.com/Quantinuum/guppylang/issues/1337)) ([8e2eba7](https://github.com/Quantinuum/guppylang/commit/8e2eba7e75e965405a903308b237344b83a3b168)), closes [#1335](https://github.com/Quantinuum/guppylang/issues/1335)
31
+ * Handle subscript borrows involving index coercions ([#1358](https://github.com/Quantinuum/guppylang/issues/1358)) ([aee0dd8](https://github.com/Quantinuum/guppylang/commit/aee0dd8b34932b6badef6b9336a7f350e241815b)), closes [#1356](https://github.com/Quantinuum/guppylang/issues/1356)
32
+
33
+
34
+ ### Miscellaneous Chores
35
+
36
+ * Remove `SumType` ([#1345](https://github.com/Quantinuum/guppylang/issues/1345)) ([b914dfe](https://github.com/Quantinuum/guppylang/commit/b914dfe374a6d7c2a4fe9f95d4f6e8f2ac0675e7))
37
+
38
+
39
+ ### Code Refactoring
40
+
41
+ * Implement `result` using overloads instead of a custom node ([#1361](https://github.com/Quantinuum/guppylang/issues/1361)) ([1da2c5d](https://github.com/Quantinuum/guppylang/commit/1da2c5dbb82bf6da35949b505a69f4e2f51acd3b))
42
+ * Store function argument names in `FuncInput` ([#1286](https://github.com/Quantinuum/guppylang/issues/1286)) ([b701840](https://github.com/Quantinuum/guppylang/commit/b70184098a65cde48c82da89ccbb4e50d1750f1d))
43
+
44
+ ## [0.25.0](https://github.com/quantinuum/guppylang/compare/guppylang-internals-v0.24.0...guppylang-internals-v0.25.0) (2025-10-28)
45
+
46
+
47
+ ### ⚠ BREAKING CHANGES
48
+
49
+ * (guppy-internals) Arrays are now lowered to `borrow_array`s instead of `value_array`s so elements do no longer need to be wrapped in options during lowering.
50
+ * `checker.core.requires_monomorphization` renamed into `require_monomorphization` and now operating on all parameters simultaneously `tys.subst.BoundVarFinder` removed. Instead, use the new `bound_vars` property on types, arguments, and consts. `tys.parsing.parse_parameter` now requires a `param_var_mapping`.
51
+
52
+ ### Features
53
+
54
+ * compiler for modifiers ([#1287](https://github.com/quantinuum/guppylang/issues/1287)) ([439ff1a](https://github.com/quantinuum/guppylang/commit/439ff1ae6bd872bb7a6eb5441110d2febebd1e47))
55
+ * modifiers in CFG and its type checker (experimental) ([#1281](https://github.com/quantinuum/guppylang/issues/1281)) ([fe85018](https://github.com/quantinuum/guppylang/commit/fe8501854507c3c43cec2f26bba75198766a4a17))
56
+ * Turn type parameters into dependent telescopes ([#1154](https://github.com/quantinuum/guppylang/issues/1154)) ([b56e056](https://github.com/quantinuum/guppylang/commit/b56e056a6b4795c778ed8124a09a194fb1d97dda))
57
+ * update hugr, tket-exts and tket ([#1305](https://github.com/quantinuum/guppylang/issues/1305)) ([6990d85](https://github.com/quantinuum/guppylang/commit/6990d850170e6901f60ef1d1e718c99349105b56))
58
+ * Use `borrow_array` instead of `value_array` for array lowering ([#1166](https://github.com/quantinuum/guppylang/issues/1166)) ([f9ef42b](https://github.com/quantinuum/guppylang/commit/f9ef42b2baf61c3e1c2cfcf7bd1f3bcac33a1a25))
59
+
60
+
61
+ ### Bug Fixes
62
+
63
+ * compilation of affine-bounded type variables ([#1308](https://github.com/quantinuum/guppylang/issues/1308)) ([49ecb49](https://github.com/quantinuum/guppylang/commit/49ecb497bf450d0853baec1de9c516a3804a80eb))
64
+ * Detect unsolved generic parameters even if they are unused ([#1279](https://github.com/quantinuum/guppylang/issues/1279)) ([f830db0](https://github.com/quantinuum/guppylang/commit/f830db00c416cfc1e9fe7ec70c612b6b558aa740)), closes [#1273](https://github.com/quantinuum/guppylang/issues/1273)
65
+ * Fix bug in symbolic pytket circuit loading with arrays ([#1302](https://github.com/quantinuum/guppylang/issues/1302)) ([e6b90e8](https://github.com/quantinuum/guppylang/commit/e6b90e8e4d275d36514a75e87eb097383495a291)), closes [#1298](https://github.com/quantinuum/guppylang/issues/1298)
66
+ * Improve track_hugr_side_effects, adding Order edges from/to Input/Output ([#1311](https://github.com/quantinuum/guppylang/issues/1311)) ([3c6ce7a](https://github.com/quantinuum/guppylang/commit/3c6ce7aaf7a1c93c6412501976fc97afd61a062d))
67
+ * multiline loop arguments ([#1309](https://github.com/quantinuum/guppylang/issues/1309)) ([836ef72](https://github.com/quantinuum/guppylang/commit/836ef722d8f8bdb02c56e5f06934246a718e68d3))
68
+
69
+ ## [0.24.0](https://github.com/quantinuum/guppylang/compare/guppylang-internals-v0.23.0...guppylang-internals-v0.24.0) (2025-09-19)
70
+
71
+
72
+ ### ⚠ BREAKING CHANGES
73
+
74
+ * `guppylang_internals.decorator.extend_type` now returns a `GuppyDefinition` by default. To get the previous behaviour of returning the annotated class unchanged, pass `return_class=True`.
75
+ * `TypeDef`s now require a `params` field
76
+ * guppylang_internals.ty.parsing.parse_function_io_types replaced with parse_function_arg_annotation and check_function_arg
77
+ * Significant changes to the WASM decorators, types and operations
78
+ * Deleted `guppylang_internals.nodes.{IterHasNext, IterEnd}`
79
+ * guppylang_internals.tracing.unpacking.update_packed_value now returns a bool signalling whether the operation was successful.
80
+ * `CompilationEngine` now initialises all it's fields
81
+ * Calling `CompilationEngine.reset` no longer nullifies `additional_extensions`
82
+ * `CompilationEngine.register_extension` no longer adds duplicates to the `additional_extensions` list
83
+
84
+ ### Features
85
+
86
+ * Infer type of `self` arguments ([#1192](https://github.com/quantinuum/guppylang/issues/1192)) ([51f5a2b](https://github.com/quantinuum/guppylang/commit/51f5a2b3a9b06bc4ab054f32a4d07f7395df8ff4))
87
+
88
+
89
+ ### Bug Fixes
90
+
91
+ * Add init to CompilationEngine; don't trash additional_extensions ([#1256](https://github.com/quantinuum/guppylang/issues/1256)) ([e413748](https://github.com/quantinuum/guppylang/commit/e413748532db3895cab4925a222177a4fa3fd61b))
92
+ * Allow generic specialization of methods ([#1206](https://github.com/quantinuum/guppylang/issues/1206)) ([93936cc](https://github.com/quantinuum/guppylang/commit/93936cc275c56dd856d11fabc7aac20176304147)), closes [#1182](https://github.com/quantinuum/guppylang/issues/1182)
93
+ * Correctly update borrowed values after calls and catch cases where it's impossible ([#1253](https://github.com/quantinuum/guppylang/issues/1253)) ([3ec5462](https://github.com/quantinuum/guppylang/commit/3ec54627729b49689da006a743e9e2c359cd3728))
94
+ * Fix `nat` constructor in comptime functions ([#1258](https://github.com/quantinuum/guppylang/issues/1258)) ([e257b6f](https://github.com/quantinuum/guppylang/commit/e257b6fc2fe3793d6d8f63feca83bf5ed6643673))
95
+ * Fix incorrect leak error for borrowing functions in comptime ([#1252](https://github.com/quantinuum/guppylang/issues/1252)) ([855244e](https://github.com/quantinuum/guppylang/commit/855244e2d5e3aeb04c2028f9f2310dba0e74210a)), closes [#1249](https://github.com/quantinuum/guppylang/issues/1249)
96
+ * wasm module updates based on tested lowering ([#1230](https://github.com/quantinuum/guppylang/issues/1230)) ([657cea2](https://github.com/quantinuum/guppylang/commit/657cea27af00a9c02e8d1a3190db535bbd1e7981))
97
+
98
+
99
+ ### Miscellaneous Chores
100
+
101
+ * Delete unused old iterator AST nodes ([#1215](https://github.com/quantinuum/guppylang/issues/1215)) ([2310897](https://github.com/quantinuum/guppylang/commit/231089750e33cf70754e5218feed64053c558c17))
102
+
103
+ ## [0.23.0](https://github.com/quantinuum/guppylang/compare/guppylang-internals-v0.22.0...guppylang-internals-v0.23.0) (2025-08-19)
104
+
105
+
106
+ ### ⚠ BREAKING CHANGES
107
+
108
+ * `check_rows_match` no longer takes `globals` Deleted `GlobalShadowError` and `BranchTypeError.GlobalHint`
109
+
110
+ ### Bug Fixes
111
+
112
+ * Fix globals vs locals scoping behaviour to match Python ([#1169](https://github.com/quantinuum/guppylang/issues/1169)) ([a6a91ca](https://github.com/quantinuum/guppylang/commit/a6a91ca32ad7c67bf1d733eb26c016a2662256ef))
113
+ * Fix scoping issues with comprehensions in comptime expressions ([#1218](https://github.com/quantinuum/guppylang/issues/1218)) ([0b990e2](https://github.com/quantinuum/guppylang/commit/0b990e2b006c31352675004aec63a857f03a0793))
114
+
115
+
116
+ ### Documentation
117
+
118
+ * use results sequence protocol for simplicity ([#1208](https://github.com/quantinuum/guppylang/issues/1208)) ([f9c1aee](https://github.com/quantinuum/guppylang/commit/f9c1aee38776c678660ede5495989ac4d75baaeb))
119
+
120
+ ## [0.22.0](https://github.com/quantinuum/guppylang/compare/guppylang-internals-v0.21.2...guppylang-internals-v0.22.0) (2025-08-11)
121
+
122
+
123
+ ### ⚠ BREAKING CHANGES
124
+
125
+ * RangeChecker has been deleted.
126
+
127
+ ### Features
128
+
129
+ * Add float parameter inputs to symbolic pytket circuits ([#1105](https://github.com/quantinuum/guppylang/issues/1105)) ([34c546c](https://github.com/quantinuum/guppylang/commit/34c546c3b5787beb839687fdbf4db8bc94f36c4a)), closes [#1076](https://github.com/quantinuum/guppylang/issues/1076)
130
+ * Allow custom start and step in `range` ([#1157](https://github.com/quantinuum/guppylang/issues/1157)) ([a1b9333](https://github.com/quantinuum/guppylang/commit/a1b9333712c74270d5efaaa72f83d6b09047c068))
131
+ * Improve codegen for array unpacking ([#1106](https://github.com/quantinuum/guppylang/issues/1106)) ([f375097](https://github.com/quantinuum/guppylang/commit/f3750973a719b03d27668a3ae39f58c8424deffc))
132
+ * Insert drop ops for affine values ([#1090](https://github.com/quantinuum/guppylang/issues/1090)) ([083133e](https://github.com/quantinuum/guppylang/commit/083133e809873fce265bb78547fc3e519cb66ea1))
133
+
134
+
135
+ ### Bug Fixes
136
+
137
+ * Fix builtins mock escaping the tracing scope ([#1161](https://github.com/quantinuum/guppylang/issues/1161)) ([a27a5c1](https://github.com/quantinuum/guppylang/commit/a27a5c19560d76e46678f846476ea86e873ac8ac))
138
+
139
+ ## [0.21.1](https://github.com/quantinuum/guppylang/compare/guppylang-internals-v0.21.0...guppylang-internals-v0.21.1) (2025-08-05)
140
+
141
+
142
+ ### Bug Fixes
143
+
144
+ * **guppylang-internals:** Fix circular import for custom decorators ([#1146](https://github.com/quantinuum/guppylang/issues/1146)) ([d8474d8](https://github.com/quantinuum/guppylang/commit/d8474d8af3d394275268cd3d0754ff06ecb9bcc2)), closes [#1145](https://github.com/quantinuum/guppylang/issues/1145)
145
+ * Support `None` value ([#1149](https://github.com/quantinuum/guppylang/issues/1149)) ([7f606c7](https://github.com/quantinuum/guppylang/commit/7f606c778d98312a0d1c4a9c7a27448c24d80585)), closes [#1148](https://github.com/quantinuum/guppylang/issues/1148)
146
+
147
+
148
+ ### Documentation
149
+
150
+ * Fix docs build ([#1142](https://github.com/quantinuum/guppylang/issues/1142)) ([4dfd575](https://github.com/quantinuum/guppylang/commit/4dfd575bcdfdf1e2db4e61f2f406fff27e0c08f7))
151
+
152
+ ## [0.21.0](https://github.com/quantinuum/guppylang/compare/guppylang-internals-v0.20.0...guppylang-internals-v0.21.0) (2025-08-04)
153
+
154
+
155
+ ### ⚠ BREAKING CHANGES
156
+
157
+ * All compiler-internal and non-userfacing functionality is moved into a new `guppylang_internals` package
158
+
159
+ ### Code Refactoring
160
+
161
+ * Split up into `guppylang_internals` package ([#1126](https://github.com/quantinuum/guppylang/issues/1126)) ([81d50c0](https://github.com/quantinuum/guppylang/commit/81d50c0a24f55eca48d62e4b0275ef2126c5e626))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: guppylang-internals
3
- Version: 0.25.0
3
+ Version: 0.26.0
4
4
  Summary: Compiler internals for `guppylang` package.
5
5
  Author-email: Mark Koch <mark.koch@quantinuum.com>, TKET development team <tket-support@quantinuum.com>
6
6
  Maintainer-email: Mark Koch <mark.koch@quantinuum.com>, TKET development team <tket-support@quantinuum.com>
@@ -222,6 +222,7 @@ Requires-Python: <4,>=3.10
222
222
  Requires-Dist: hugr~=0.14.1
223
223
  Requires-Dist: tket-exts~=0.12.0
224
224
  Requires-Dist: typing-extensions<5,>=4.9.0
225
+ Requires-Dist: wasmtime~=v38.0.0
225
226
  Provides-Extra: pytket
226
227
  Requires-Dist: pytket>=1.34; extra == 'pytket'
227
228
  Description-Content-Type: text/markdown
@@ -244,10 +245,10 @@ pip install guppylang-internals
244
245
 
245
246
  See [DEVELOPMENT.md] information on how to develop and contribute to this package.
246
247
 
247
- [DEVELOPMENT.md]: https://github.com/CQCL/guppylang/blob/main/DEVELOPMENT.md
248
+ [DEVELOPMENT.md]: https://github.com/quantinuum/guppylang/blob/main/DEVELOPMENT.md
248
249
 
249
250
  ## License
250
251
 
251
252
  This project is licensed under Apache License, Version 2.0 ([LICENCE][] or http://www.apache.org/licenses/LICENSE-2.0).
252
253
 
253
- [LICENCE]: https://github.com/CQCL/guppylang/blob/main/LICENCE
254
+ [LICENCE]: https://github.com/quantinuum/guppylang/blob/main/LICENCE
@@ -16,10 +16,10 @@ pip install guppylang-internals
16
16
 
17
17
  See [DEVELOPMENT.md] information on how to develop and contribute to this package.
18
18
 
19
- [DEVELOPMENT.md]: https://github.com/CQCL/guppylang/blob/main/DEVELOPMENT.md
19
+ [DEVELOPMENT.md]: https://github.com/quantinuum/guppylang/blob/main/DEVELOPMENT.md
20
20
 
21
21
  ## License
22
22
 
23
23
  This project is licensed under Apache License, Version 2.0 ([LICENCE][] or http://www.apache.org/licenses/LICENSE-2.0).
24
24
 
25
- [LICENCE]: https://github.com/CQCL/guppylang/blob/main/LICENCE
25
+ [LICENCE]: https://github.com/quantinuum/guppylang/blob/main/LICENCE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "guppylang-internals"
3
- version = "0.25.0"
3
+ version = "0.26.0"
4
4
  requires-python = ">=3.10,<4"
5
5
  description = "Compiler internals for `guppylang` package."
6
6
  license = { file = "LICENCE" }
@@ -36,6 +36,7 @@ dependencies = [
36
36
  "typing-extensions >=4.9.0,<5",
37
37
  "tket-exts ~= 0.12.0",
38
38
  "hugr ~= 0.14.1",
39
+ "wasmtime ~= v38.0.0",
39
40
  ]
40
41
 
41
42
  [project.optional-dependencies]
@@ -1,3 +1,3 @@
1
1
  # This is updated by our release-please workflow, triggered by this
2
2
  # annotation: x-release-please-version
3
- __version__ = "0.25.0"
3
+ __version__ = "0.26.0"
@@ -46,7 +46,7 @@ from guppylang_internals.nodes import (
46
46
  Power,
47
47
  )
48
48
  from guppylang_internals.span import Span, to_span
49
- from guppylang_internals.tys.ty import NoneType
49
+ from guppylang_internals.tys.ty import NoneType, UnitaryFlags
50
50
 
51
51
  # In order to build expressions, need an endless stream of unique temporary variables
52
52
  # to store intermediate results
@@ -78,7 +78,13 @@ class CFGBuilder(AstVisitor[BB | None]):
78
78
  cfg: CFG
79
79
  globals: Globals
80
80
 
81
- def build(self, nodes: list[ast.stmt], returns_none: bool, globals: Globals) -> CFG:
81
+ def build(
82
+ self,
83
+ nodes: list[ast.stmt],
84
+ returns_none: bool,
85
+ globals: Globals,
86
+ unitary_flags: UnitaryFlags = UnitaryFlags.NoFlags,
87
+ ) -> CFG:
82
88
  """Builds a CFG from a list of ast nodes.
83
89
 
84
90
  We also require the expected number of return ports for the whole CFG. This is
@@ -86,6 +92,7 @@ class CFGBuilder(AstVisitor[BB | None]):
86
92
  variables.
87
93
  """
88
94
  self.cfg = CFG()
95
+ self.cfg.unitary_flags = unitary_flags
89
96
  self.globals = globals
90
97
 
91
98
  final_bb = self.visit_stmts(
@@ -273,6 +280,7 @@ class CFGBuilder(AstVisitor[BB | None]):
273
280
 
274
281
  func_ty = check_signature(node, self.globals)
275
282
  returns_none = isinstance(func_ty.output, NoneType)
283
+ # No UnitaryFlags are assigned to nested functions
276
284
  cfg = CFGBuilder().build(node.body, returns_none, self.globals)
277
285
 
278
286
  new_node = NestedFunctionDef(
@@ -300,6 +308,13 @@ class CFGBuilder(AstVisitor[BB | None]):
300
308
  modifier = self._handle_withitem(item)
301
309
  new_node.push_modifier(modifier)
302
310
 
311
+ # FIXME: Currently, the unitary flags is not set correctly if there are nested
312
+ # `with` blocks. This is because the outer block's unitary flags are not
313
+ # propagated to the outer block. The following line should calculate the sum
314
+ # of the unitary flags of the outer block and modifiers applied in this
315
+ # `with` block.
316
+ cfg.unitary_flags = new_node.flags()
317
+
303
318
  set_location_from(new_node, node)
304
319
  bb.statements.append(new_node)
305
320
  return bb
@@ -12,6 +12,7 @@ from guppylang_internals.cfg.analysis import (
12
12
  )
13
13
  from guppylang_internals.cfg.bb import BB, BBStatement, VariableStats
14
14
  from guppylang_internals.nodes import InoutReturnSentinel
15
+ from guppylang_internals.tys.ty import UnitaryFlags
15
16
 
16
17
  T = TypeVar("T", bound=BB)
17
18
 
@@ -29,6 +30,7 @@ class BaseCFG(Generic[T]):
29
30
 
30
31
  #: Set of variables defined in this CFG
31
32
  assigned_somewhere: set[str]
33
+ unitary_flags: UnitaryFlags
32
34
 
33
35
  def __init__(
34
36
  self, bbs: list[T], entry_bb: T | None = None, exit_bb: T | None = None
@@ -42,6 +44,7 @@ class BaseCFG(Generic[T]):
42
44
  self.ass_before = {}
43
45
  self.maybe_ass_before = {}
44
46
  self.assigned_somewhere = set()
47
+ self.unitary_flags = UnitaryFlags.NoFlags
45
48
 
46
49
  def ancestors(self, *bbs: T) -> Iterator[T]:
47
50
  """Returns an iterator over all ancestors of the given BBs in BFS order."""
@@ -149,11 +149,17 @@ def check_cfg(
149
149
  checked_cfg.maybe_ass_before = {
150
150
  compiled[bb]: cfg.maybe_ass_before[bb] for bb in required_bbs
151
151
  }
152
+ checked_cfg.unitary_flags = cfg.unitary_flags
152
153
 
153
154
  # Finally, run the linearity check
154
155
  from guppylang_internals.checker.linearity_checker import check_cfg_linearity
155
156
 
156
157
  linearity_checked_cfg = check_cfg_linearity(checked_cfg, func_name, globals)
158
+
159
+ from guppylang_internals.checker.unitary_checker import check_cfg_unitary
160
+
161
+ check_cfg_unitary(linearity_checked_cfg, cfg.unitary_flags)
162
+
157
163
  return linearity_checked_cfg
158
164
 
159
165
 
@@ -47,7 +47,6 @@ from guppylang_internals.tys.ty import (
47
47
  NumericType,
48
48
  OpaqueType,
49
49
  StructType,
50
- SumType,
51
50
  TupleType,
52
51
  Type,
53
52
  )
@@ -360,7 +359,7 @@ class Globals:
360
359
  match ty:
361
360
  case TypeDef() as type_defn:
362
361
  pass
363
- case BoundTypeVar() | ExistentialTypeVar() | SumType():
362
+ case BoundTypeVar() | ExistentialTypeVar():
364
363
  return None
365
364
  case NumericType(kind):
366
365
  match kind:
@@ -1,7 +1,7 @@
1
1
  from dataclasses import dataclass
2
2
  from typing import ClassVar
3
3
 
4
- from guppylang_internals.diagnostic import Error
4
+ from guppylang_internals.diagnostic import Error, Note
5
5
  from guppylang_internals.tys.ty import Type
6
6
 
7
7
 
@@ -13,10 +13,13 @@ class WasmError(Error):
13
13
  @dataclass(frozen=True)
14
14
  class FirstArgNotModule(WasmError):
15
15
  span_label: ClassVar[str] = (
16
- "First argument to WASM function should be a reference to a WASM module."
17
- " Found `{ty}` instead"
16
+ "First argument to WASM function should be a WASM module."
18
17
  )
19
- ty: Type
18
+
19
+ @dataclass(frozen=True)
20
+ class GotOtherType(Note):
21
+ span_label: ClassVar[str] = "Found `{ty}` instead."
22
+ ty: Type
20
23
 
21
24
 
22
25
  @dataclass(frozen=True)
@@ -43,6 +43,7 @@ from guppylang_internals.ast_util import (
43
43
  )
44
44
  from guppylang_internals.cfg.builder import is_tmp_var, tmp_vars
45
45
  from guppylang_internals.checker.core import (
46
+ ComptimeVariable,
46
47
  Context,
47
48
  DummyEvalDict,
48
49
  FieldAccess,
@@ -468,7 +469,7 @@ class ExprSynthesizer(AstVisitor[tuple[ast.expr, Type]]):
468
469
  # The only exception are attributes accesses that are generated during
469
470
  # desugaring (for example for iterators in `for` loops). Since those just
470
471
  # inherit the span of the sugared code, we could have line breaks there.
471
- # See https://github.com/CQCL/guppylang/issues/1301
472
+ # See https://github.com/quantinuum/guppylang/issues/1301
472
473
  span = to_span(node)
473
474
  if span.start.line == span.end.line:
474
475
  attr_span = Span(span.end.shift_left(len(node.attr)), span.end)
@@ -503,12 +504,7 @@ class ExprSynthesizer(AstVisitor[tuple[ast.expr, Type]]):
503
504
  )
504
505
  # Make a closure by partially applying the `self` argument
505
506
  # TODO: Try to infer some type args based on `self`
506
- result_ty = FunctionType(
507
- func.ty.inputs[1:],
508
- func.ty.output,
509
- func.ty.input_names[1:] if func.ty.input_names else None,
510
- func.ty.params,
511
- )
507
+ result_ty = FunctionType(func.ty.inputs[1:], func.ty.output, func.ty.params)
512
508
  return with_loc(node, PartialApply(func=name, args=[node.value])), result_ty
513
509
  raise GuppyTypeError(AttributeNotFoundError(attr_span, ty, node.attr))
514
510
 
@@ -1035,7 +1031,14 @@ def check_place_assignable(
1035
1031
  exp_sig = FunctionType(
1036
1032
  [
1037
1033
  FuncInput(parent.ty, InputFlags.Inout),
1038
- FuncInput(item.ty, InputFlags.NoFlags),
1034
+ FuncInput(
1035
+ # Due to potential coercions that were applied during the
1036
+ # `__getitem__` call (e.g. coercing a nat index to int), we're
1037
+ # not allowed to rely on `item.ty` here.
1038
+ # See https://github.com/CQCL/guppylang/issues/1356
1039
+ ExistentialTypeVar.fresh("T", True, True),
1040
+ InputFlags.NoFlags,
1041
+ ),
1039
1042
  FuncInput(ty, InputFlags.Owned),
1040
1043
  ],
1041
1044
  NoneType(),
@@ -1072,6 +1075,8 @@ def check_comptime_arg(
1072
1075
  match arg:
1073
1076
  case ast.Constant(value=v):
1074
1077
  const = ConstValue(ty, v)
1078
+ case PlaceNode(place=ComptimeVariable(ty=ty, static_value=v)):
1079
+ const = ConstValue(ty, v)
1075
1080
  case GenericParamValue(param=const_param):
1076
1081
  const = const_param.to_bound().const
1077
1082
  case arg:
@@ -16,6 +16,7 @@ from guppylang_internals.cfg.builder import CFGBuilder
16
16
  from guppylang_internals.checker.cfg_checker import CheckedCFG, check_cfg
17
17
  from guppylang_internals.checker.core import Context, Globals, Place, Variable
18
18
  from guppylang_internals.checker.errors.generic import UnsupportedError
19
+ from guppylang_internals.checker.unitary_checker import check_invalid_under_dagger
19
20
  from guppylang_internals.definition.common import DefId
20
21
  from guppylang_internals.definition.ty import TypeDef
21
22
  from guppylang_internals.diagnostic import Error, Help, Note
@@ -37,6 +38,7 @@ from guppylang_internals.tys.ty import (
37
38
  InputFlags,
38
39
  NoneType,
39
40
  Type,
41
+ UnitaryFlags,
40
42
  unify,
41
43
  )
42
44
 
@@ -134,12 +136,13 @@ def check_global_func_def(
134
136
  """Type checks a top-level function definition."""
135
137
  args = func_def.args.args
136
138
  returns_none = isinstance(ty.output, NoneType)
137
- assert ty.input_names is not None
139
+ assert all(inp.name is not None for inp in ty.inputs)
138
140
 
139
- cfg = CFGBuilder().build(func_def.body, returns_none, globals)
141
+ check_invalid_under_dagger(func_def, ty.unitary_flags)
142
+ cfg = CFGBuilder().build(func_def.body, returns_none, globals, ty.unitary_flags)
140
143
  inputs = [
141
- Variable(x, inp.ty, loc, inp.flags, is_func_input=True)
142
- for x, inp, loc in zip(ty.input_names, ty.inputs, args, strict=True)
144
+ Variable(cast(str, inp.name), inp.ty, loc, inp.flags, is_func_input=True)
145
+ for inp, loc in zip(ty.inputs, args, strict=True)
143
146
  # Comptime inputs are turned into generic args, so are not included here
144
147
  if InputFlags.Comptime not in inp.flags
145
148
  ]
@@ -150,7 +153,9 @@ def check_global_func_def(
150
153
 
151
154
 
152
155
  def check_nested_func_def(
153
- func_def: NestedFunctionDef, bb: BB, ctx: Context
156
+ func_def: NestedFunctionDef,
157
+ bb: BB,
158
+ ctx: Context,
154
159
  ) -> CheckedNestedFunctionDef:
155
160
  """Type checks a local (nested) function definition."""
156
161
  func_ty = check_signature(func_def, ctx.globals)
@@ -194,10 +199,8 @@ def check_nested_func_def(
194
199
 
195
200
  # Construct inputs for checking the body CFG
196
201
  inputs = [v for v, _ in captured.values()] + [
197
- Variable(x, inp.ty, func_def.args.args[i], inp.flags, is_func_input=True)
198
- for i, (x, inp) in enumerate(
199
- zip(func_ty.input_names, func_ty.inputs, strict=True)
200
- )
202
+ Variable(cast(str, inp.name), inp.ty, arg, inp.flags, is_func_input=True)
203
+ for arg, inp in zip(func_def.args.args, func_ty.inputs, strict=True)
201
204
  # Comptime inputs are turned into generic args, so are not included here
202
205
  if InputFlags.Comptime not in inp.flags
203
206
  ]
@@ -238,7 +241,10 @@ def check_nested_func_def(
238
241
 
239
242
 
240
243
  def check_signature(
241
- func_def: ast.FunctionDef, globals: Globals, def_id: DefId | None = None
244
+ func_def: ast.FunctionDef,
245
+ globals: Globals,
246
+ def_id: DefId | None = None,
247
+ unitary_flags: UnitaryFlags = UnitaryFlags.NoFlags,
242
248
  ) -> FunctionType:
243
249
  """Checks the signature of a function definition and returns the corresponding
244
250
  Guppy type.
@@ -286,7 +292,6 @@ def check_signature(
286
292
  assert isinstance(self_defn, TypeDef)
287
293
 
288
294
  inputs = []
289
- input_names = []
290
295
  ctx = TypeParsingCtx(globals, param_var_mapping, allow_free_vars=True)
291
296
  for i, inp in enumerate(func_def.args.args):
292
297
  # Special handling for `self` arguments. Note that `__new__` is excluded here
@@ -300,13 +305,12 @@ def check_signature(
300
305
  raise GuppyError(MissingArgAnnotationError(inp))
301
306
  input = parse_function_arg_annotation(ty_ast, inp.arg, ctx)
302
307
  inputs.append(input)
303
- input_names.append(inp.arg)
304
308
  output = type_from_ast(func_def.returns, ctx)
305
309
  return FunctionType(
306
310
  inputs,
307
311
  output,
308
- input_names,
309
312
  sorted(param_var_mapping.values(), key=lambda v: v.idx),
313
+ unitary_flags=unitary_flags,
310
314
  )
311
315
 
312
316
 
@@ -63,7 +63,6 @@ from guppylang_internals.nodes import (
63
63
  LocalCall,
64
64
  PartialApply,
65
65
  PlaceNode,
66
- ResultExpr,
67
66
  StateResultExpr,
68
67
  SubscriptAccessAndDrop,
69
68
  TensorCall,
@@ -74,7 +73,6 @@ from guppylang_internals.tys.ty import (
74
73
  FuncInput,
75
74
  FunctionType,
76
75
  InputFlags,
77
- NoneType,
78
76
  StructType,
79
77
  TupleType,
80
78
  Type,
@@ -451,13 +449,6 @@ class BBLinearityChecker(ast.NodeVisitor):
451
449
  self._visit_call_args(node.func_ty, node)
452
450
  self._reassign_inout_args(node.func_ty, node)
453
451
 
454
- def visit_ResultExpr(self, node: ResultExpr) -> None:
455
- ty = get_type(node.value)
456
- flag = InputFlags.Inout if not ty.copyable else InputFlags.NoFlags
457
- func_ty = FunctionType([FuncInput(ty, flag)], NoneType())
458
- self._visit_call_args(func_ty, node)
459
- self._reassign_inout_args(func_ty, node)
460
-
461
452
  def visit_StateResultExpr(self, node: StateResultExpr) -> None:
462
453
  self._visit_call_args(node.func_ty, node)
463
454
  self._reassign_inout_args(node.func_ty, node)
@@ -582,7 +573,7 @@ class BBLinearityChecker(ast.NodeVisitor):
582
573
  # can feed them through the loop. Note that we could also use non-local
583
574
  # edges, but we can't handle them in lower parts of the stack yet :/
584
575
  # TODO: Reinstate use of non-local edges.
585
- # See https://github.com/CQCL/guppylang/issues/963
576
+ # See https://github.com/quantinuum/guppylang/issues/963
586
577
  gen.used_outer_places = []
587
578
  for x, use in inner_scope.used_parent.items():
588
579
  place = inner_scope[x]
@@ -880,6 +871,7 @@ def check_cfg_linearity(
880
871
  result_cfg.maybe_ass_before = {
881
872
  checked[bb]: cfg.maybe_ass_before[bb] for bb in cfg.bbs
882
873
  }
874
+ result_cfg.unitary_flags = cfg.unitary_flags
883
875
  for bb in cfg.bbs:
884
876
  checked[bb].predecessors = [checked[pred] for pred in bb.predecessors]
885
877
  checked[bb].successors = [checked[succ] for succ in bb.successors]
@@ -71,7 +71,7 @@ def check_modified_block(
71
71
  # This name could be printed in error messages, for example,
72
72
  # when the linearity checker fails in the modifier body
73
73
  checked_cfg = check_cfg(cfg, inputs, NoneType(), {}, "__modified__()", globals)
74
- func_ty = check_modified_block_signature(checked_cfg.input_tys)
74
+ func_ty = check_modified_block_signature(modified_block, checked_cfg.input_tys)
75
75
 
76
76
  checked_modifier = CheckedModifiedBlock(
77
77
  def_id,
@@ -94,9 +94,12 @@ def _set_inout_if_non_copyable(var: Variable) -> Variable:
94
94
  return var
95
95
 
96
96
 
97
- def check_modified_block_signature(input_tys: list[Type]) -> FunctionType:
97
+ def check_modified_block_signature(
98
+ modified_block: ModifiedBlock, input_tys: list[Type]
99
+ ) -> FunctionType:
98
100
  """Check and create the signature of a function definition for a body
99
101
  of a `With` block."""
102
+ unitary_flags = modified_block.flags()
100
103
 
101
104
  func_ty = FunctionType(
102
105
  [
@@ -104,6 +107,7 @@ def check_modified_block_signature(input_tys: list[Type]) -> FunctionType:
104
107
  for t in input_tys
105
108
  ],
106
109
  NoneType(),
110
+ unitary_flags=unitary_flags,
107
111
  )
108
112
  return func_ty
109
113