guppylang-internals 0.23.0__tar.gz → 0.25.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 (105) hide show
  1. guppylang_internals-0.25.0/CHANGELOG.md +123 -0
  2. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/PKG-INFO +4 -4
  3. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/README.md +1 -1
  4. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/pyproject.toml +3 -3
  5. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/__init__.py +1 -1
  6. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/ast_util.py +21 -0
  7. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/cfg/bb.py +20 -0
  8. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/cfg/builder.py +101 -3
  9. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/core.py +12 -0
  10. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/errors/generic.py +32 -1
  11. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/errors/type_errors.py +14 -0
  12. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/expr_checker.py +55 -29
  13. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/func_checker.py +171 -22
  14. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/linearity_checker.py +65 -0
  15. guppylang_internals-0.25.0/src/guppylang_internals/checker/modifier_checker.py +116 -0
  16. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/stmt_checker.py +49 -2
  17. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/compiler/core.py +90 -53
  18. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/compiler/expr_compiler.py +49 -114
  19. guppylang_internals-0.25.0/src/guppylang_internals/compiler/modifier_compiler.py +174 -0
  20. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/compiler/stmt_compiler.py +15 -8
  21. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/decorator.py +124 -58
  22. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/const.py +2 -2
  23. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/custom.py +36 -2
  24. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/declaration.py +4 -5
  25. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/extern.py +2 -2
  26. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/function.py +1 -1
  27. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/parameter.py +10 -5
  28. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/pytket_circuits.py +14 -42
  29. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/struct.py +17 -14
  30. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/traced.py +1 -1
  31. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/ty.py +9 -3
  32. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/wasm.py +2 -2
  33. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/engine.py +13 -2
  34. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/experimental.py +5 -0
  35. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/nodes.py +124 -23
  36. guppylang_internals-0.25.0/src/guppylang_internals/std/_internal/compiler/array.py +381 -0
  37. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/tket_exts.py +12 -8
  38. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/wasm.py +37 -26
  39. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tracing/function.py +13 -2
  40. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tracing/unpacking.py +33 -28
  41. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tys/arg.py +18 -3
  42. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tys/builtin.py +32 -16
  43. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tys/const.py +33 -4
  44. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tys/errors.py +6 -0
  45. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tys/param.py +31 -16
  46. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tys/parsing.py +118 -145
  47. guppylang_internals-0.25.0/src/guppylang_internals/tys/qubit.py +27 -0
  48. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tys/subst.py +8 -26
  49. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tys/ty.py +31 -21
  50. guppylang_internals-0.23.0/CHANGELOG.md +0 -64
  51. guppylang_internals-0.23.0/src/guppylang_internals/std/_internal/compiler/array.py +0 -569
  52. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/.gitignore +0 -0
  53. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/LICENCE +0 -0
  54. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/cfg/__init__.py +0 -0
  55. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/cfg/analysis.py +0 -0
  56. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/cfg/cfg.py +0 -0
  57. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/__init__.py +0 -0
  58. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/cfg_checker.py +0 -0
  59. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/errors/__init__.py +0 -0
  60. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/errors/comptime_errors.py +0 -0
  61. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/errors/linearity.py +0 -0
  62. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/checker/errors/wasm.py +0 -0
  63. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/compiler/__init__.py +0 -0
  64. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/compiler/cfg_compiler.py +0 -0
  65. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/compiler/func_compiler.py +0 -0
  66. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/compiler/hugr_extension.py +0 -0
  67. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/compiler/qtm_platform_extension.py +0 -0
  68. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/__init__.py +0 -0
  69. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/common.py +0 -0
  70. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/overloaded.py +0 -0
  71. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/definition/value.py +0 -0
  72. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/diagnostic.py +0 -0
  73. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/dummy_decorator.py +0 -0
  74. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/error.py +0 -0
  75. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/ipython_inspect.py +0 -0
  76. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/py.typed +0 -0
  77. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/span.py +0 -0
  78. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/__init__.py +0 -0
  79. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/__init__.py +0 -0
  80. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/checker.py +0 -0
  81. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/__init__.py +0 -0
  82. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/arithmetic.py +0 -0
  83. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/either.py +0 -0
  84. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/frozenarray.py +0 -0
  85. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/futures.py +0 -0
  86. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/list.py +0 -0
  87. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/mem.py +0 -0
  88. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/option.py +0 -0
  89. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/prelude.py +0 -0
  90. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/qsystem.py +0 -0
  91. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/quantum.py +0 -0
  92. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler/tket_bool.py +0 -0
  93. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/compiler.py +0 -0
  94. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/debug.py +0 -0
  95. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/std/_internal/util.py +0 -0
  96. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tracing/__init__.py +0 -0
  97. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tracing/builtins_mock.py +0 -0
  98. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tracing/frozenlist.py +0 -0
  99. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tracing/object.py +0 -0
  100. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tracing/state.py +0 -0
  101. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tracing/util.py +0 -0
  102. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tys/__init__.py +0 -0
  103. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tys/common.py +0 -0
  104. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tys/printing.py +0 -0
  105. {guppylang_internals-0.23.0 → guppylang_internals-0.25.0}/src/guppylang_internals/tys/var.py +0 -0
@@ -0,0 +1,123 @@
1
+ # Changelog
2
+
3
+ First release of `guppylang_internals` package containing refactored out internal components
4
+ from `guppylang`.
5
+
6
+ ## [0.25.0](https://github.com/CQCL/guppylang/compare/guppylang-internals-v0.24.0...guppylang-internals-v0.25.0) (2025-10-28)
7
+
8
+
9
+ ### ⚠ BREAKING CHANGES
10
+
11
+ * (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.
12
+ * `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`.
13
+
14
+ ### Features
15
+
16
+ * compiler for modifiers ([#1287](https://github.com/CQCL/guppylang/issues/1287)) ([439ff1a](https://github.com/CQCL/guppylang/commit/439ff1ae6bd872bb7a6eb5441110d2febebd1e47))
17
+ * modifiers in CFG and its type checker (experimental) ([#1281](https://github.com/CQCL/guppylang/issues/1281)) ([fe85018](https://github.com/CQCL/guppylang/commit/fe8501854507c3c43cec2f26bba75198766a4a17))
18
+ * Turn type parameters into dependent telescopes ([#1154](https://github.com/CQCL/guppylang/issues/1154)) ([b56e056](https://github.com/CQCL/guppylang/commit/b56e056a6b4795c778ed8124a09a194fb1d97dda))
19
+ * update hugr, tket-exts and tket ([#1305](https://github.com/CQCL/guppylang/issues/1305)) ([6990d85](https://github.com/CQCL/guppylang/commit/6990d850170e6901f60ef1d1e718c99349105b56))
20
+ * Use `borrow_array` instead of `value_array` for array lowering ([#1166](https://github.com/CQCL/guppylang/issues/1166)) ([f9ef42b](https://github.com/CQCL/guppylang/commit/f9ef42b2baf61c3e1c2cfcf7bd1f3bcac33a1a25))
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * compilation of affine-bounded type variables ([#1308](https://github.com/CQCL/guppylang/issues/1308)) ([49ecb49](https://github.com/CQCL/guppylang/commit/49ecb497bf450d0853baec1de9c516a3804a80eb))
26
+ * Detect unsolved generic parameters even if they are unused ([#1279](https://github.com/CQCL/guppylang/issues/1279)) ([f830db0](https://github.com/CQCL/guppylang/commit/f830db00c416cfc1e9fe7ec70c612b6b558aa740)), closes [#1273](https://github.com/CQCL/guppylang/issues/1273)
27
+ * Fix bug in symbolic pytket circuit loading with arrays ([#1302](https://github.com/CQCL/guppylang/issues/1302)) ([e6b90e8](https://github.com/CQCL/guppylang/commit/e6b90e8e4d275d36514a75e87eb097383495a291)), closes [#1298](https://github.com/CQCL/guppylang/issues/1298)
28
+ * Improve track_hugr_side_effects, adding Order edges from/to Input/Output ([#1311](https://github.com/CQCL/guppylang/issues/1311)) ([3c6ce7a](https://github.com/CQCL/guppylang/commit/3c6ce7aaf7a1c93c6412501976fc97afd61a062d))
29
+ * multiline loop arguments ([#1309](https://github.com/CQCL/guppylang/issues/1309)) ([836ef72](https://github.com/CQCL/guppylang/commit/836ef722d8f8bdb02c56e5f06934246a718e68d3))
30
+
31
+ ## [0.24.0](https://github.com/CQCL/guppylang/compare/guppylang-internals-v0.23.0...guppylang-internals-v0.24.0) (2025-09-19)
32
+
33
+
34
+ ### ⚠ BREAKING CHANGES
35
+
36
+ * `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`.
37
+ * `TypeDef`s now require a `params` field
38
+ * guppylang_internals.ty.parsing.parse_function_io_types replaced with parse_function_arg_annotation and check_function_arg
39
+ * Significant changes to the WASM decorators, types and operations
40
+ * Deleted `guppylang_internals.nodes.{IterHasNext, IterEnd}`
41
+ * guppylang_internals.tracing.unpacking.update_packed_value now returns a bool signalling whether the operation was successful.
42
+ * `CompilationEngine` now initialises all it's fields
43
+ * Calling `CompilationEngine.reset` no longer nullifies `additional_extensions`
44
+ * `CompilationEngine.register_extension` no longer adds duplicates to the `additional_extensions` list
45
+
46
+ ### Features
47
+
48
+ * Infer type of `self` arguments ([#1192](https://github.com/CQCL/guppylang/issues/1192)) ([51f5a2b](https://github.com/CQCL/guppylang/commit/51f5a2b3a9b06bc4ab054f32a4d07f7395df8ff4))
49
+
50
+
51
+ ### Bug Fixes
52
+
53
+ * Add init to CompilationEngine; don't trash additional_extensions ([#1256](https://github.com/CQCL/guppylang/issues/1256)) ([e413748](https://github.com/CQCL/guppylang/commit/e413748532db3895cab4925a222177a4fa3fd61b))
54
+ * Allow generic specialization of methods ([#1206](https://github.com/CQCL/guppylang/issues/1206)) ([93936cc](https://github.com/CQCL/guppylang/commit/93936cc275c56dd856d11fabc7aac20176304147)), closes [#1182](https://github.com/CQCL/guppylang/issues/1182)
55
+ * Correctly update borrowed values after calls and catch cases where it's impossible ([#1253](https://github.com/CQCL/guppylang/issues/1253)) ([3ec5462](https://github.com/CQCL/guppylang/commit/3ec54627729b49689da006a743e9e2c359cd3728))
56
+ * Fix `nat` constructor in comptime functions ([#1258](https://github.com/CQCL/guppylang/issues/1258)) ([e257b6f](https://github.com/CQCL/guppylang/commit/e257b6fc2fe3793d6d8f63feca83bf5ed6643673))
57
+ * Fix incorrect leak error for borrowing functions in comptime ([#1252](https://github.com/CQCL/guppylang/issues/1252)) ([855244e](https://github.com/CQCL/guppylang/commit/855244e2d5e3aeb04c2028f9f2310dba0e74210a)), closes [#1249](https://github.com/CQCL/guppylang/issues/1249)
58
+ * wasm module updates based on tested lowering ([#1230](https://github.com/CQCL/guppylang/issues/1230)) ([657cea2](https://github.com/CQCL/guppylang/commit/657cea27af00a9c02e8d1a3190db535bbd1e7981))
59
+
60
+
61
+ ### Miscellaneous Chores
62
+
63
+ * Delete unused old iterator AST nodes ([#1215](https://github.com/CQCL/guppylang/issues/1215)) ([2310897](https://github.com/CQCL/guppylang/commit/231089750e33cf70754e5218feed64053c558c17))
64
+
65
+ ## [0.23.0](https://github.com/CQCL/guppylang/compare/guppylang-internals-v0.22.0...guppylang-internals-v0.23.0) (2025-08-19)
66
+
67
+
68
+ ### ⚠ BREAKING CHANGES
69
+
70
+ * `check_rows_match` no longer takes `globals` Deleted `GlobalShadowError` and `BranchTypeError.GlobalHint`
71
+
72
+ ### Bug Fixes
73
+
74
+ * Fix globals vs locals scoping behaviour to match Python ([#1169](https://github.com/CQCL/guppylang/issues/1169)) ([a6a91ca](https://github.com/CQCL/guppylang/commit/a6a91ca32ad7c67bf1d733eb26c016a2662256ef))
75
+ * Fix scoping issues with comprehensions in comptime expressions ([#1218](https://github.com/CQCL/guppylang/issues/1218)) ([0b990e2](https://github.com/CQCL/guppylang/commit/0b990e2b006c31352675004aec63a857f03a0793))
76
+
77
+
78
+ ### Documentation
79
+
80
+ * use results sequence protocol for simplicity ([#1208](https://github.com/CQCL/guppylang/issues/1208)) ([f9c1aee](https://github.com/CQCL/guppylang/commit/f9c1aee38776c678660ede5495989ac4d75baaeb))
81
+
82
+ ## [0.22.0](https://github.com/CQCL/guppylang/compare/guppylang-internals-v0.21.2...guppylang-internals-v0.22.0) (2025-08-11)
83
+
84
+
85
+ ### ⚠ BREAKING CHANGES
86
+
87
+ * RangeChecker has been deleted.
88
+
89
+ ### Features
90
+
91
+ * Add float parameter inputs to symbolic pytket circuits ([#1105](https://github.com/CQCL/guppylang/issues/1105)) ([34c546c](https://github.com/CQCL/guppylang/commit/34c546c3b5787beb839687fdbf4db8bc94f36c4a)), closes [#1076](https://github.com/CQCL/guppylang/issues/1076)
92
+ * Allow custom start and step in `range` ([#1157](https://github.com/CQCL/guppylang/issues/1157)) ([a1b9333](https://github.com/CQCL/guppylang/commit/a1b9333712c74270d5efaaa72f83d6b09047c068))
93
+ * Improve codegen for array unpacking ([#1106](https://github.com/CQCL/guppylang/issues/1106)) ([f375097](https://github.com/CQCL/guppylang/commit/f3750973a719b03d27668a3ae39f58c8424deffc))
94
+ * Insert drop ops for affine values ([#1090](https://github.com/CQCL/guppylang/issues/1090)) ([083133e](https://github.com/CQCL/guppylang/commit/083133e809873fce265bb78547fc3e519cb66ea1))
95
+
96
+
97
+ ### Bug Fixes
98
+
99
+ * Fix builtins mock escaping the tracing scope ([#1161](https://github.com/CQCL/guppylang/issues/1161)) ([a27a5c1](https://github.com/CQCL/guppylang/commit/a27a5c19560d76e46678f846476ea86e873ac8ac))
100
+
101
+ ## [0.21.1](https://github.com/CQCL/guppylang/compare/guppylang-internals-v0.21.0...guppylang-internals-v0.21.1) (2025-08-05)
102
+
103
+
104
+ ### Bug Fixes
105
+
106
+ * **guppylang-internals:** Fix circular import for custom decorators ([#1146](https://github.com/CQCL/guppylang/issues/1146)) ([d8474d8](https://github.com/CQCL/guppylang/commit/d8474d8af3d394275268cd3d0754ff06ecb9bcc2)), closes [#1145](https://github.com/CQCL/guppylang/issues/1145)
107
+ * Support `None` value ([#1149](https://github.com/CQCL/guppylang/issues/1149)) ([7f606c7](https://github.com/CQCL/guppylang/commit/7f606c778d98312a0d1c4a9c7a27448c24d80585)), closes [#1148](https://github.com/CQCL/guppylang/issues/1148)
108
+
109
+
110
+ ### Documentation
111
+
112
+ * Fix docs build ([#1142](https://github.com/CQCL/guppylang/issues/1142)) ([4dfd575](https://github.com/CQCL/guppylang/commit/4dfd575bcdfdf1e2db4e61f2f406fff27e0c08f7))
113
+
114
+ ## [0.21.0](https://github.com/CQCL/guppylang/compare/guppylang-internals-v0.20.0...guppylang-internals-v0.21.0) (2025-08-04)
115
+
116
+
117
+ ### ⚠ BREAKING CHANGES
118
+
119
+ * All compiler-internal and non-userfacing functionality is moved into a new `guppylang_internals` package
120
+
121
+ ### Code Refactoring
122
+
123
+ * Split up into `guppylang_internals` package ([#1126](https://github.com/CQCL/guppylang/issues/1126)) ([81d50c0](https://github.com/CQCL/guppylang/commit/81d50c0a24f55eca48d62e4b0275ef2126c5e626))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: guppylang-internals
3
- Version: 0.23.0
3
+ Version: 0.25.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>
@@ -219,8 +219,8 @@ Classifier: Programming Language :: Python :: 3.13
219
219
  Classifier: Programming Language :: Python :: 3.14
220
220
  Classifier: Topic :: Software Development :: Compilers
221
221
  Requires-Python: <4,>=3.10
222
- Requires-Dist: hugr~=0.13.1
223
- Requires-Dist: tket-exts~=0.10.0
222
+ Requires-Dist: hugr~=0.14.1
223
+ Requires-Dist: tket-exts~=0.12.0
224
224
  Requires-Dist: typing-extensions<5,>=4.9.0
225
225
  Provides-Extra: pytket
226
226
  Requires-Dist: pytket>=1.34; extra == 'pytket'
@@ -228,7 +228,7 @@ Description-Content-Type: text/markdown
228
228
 
229
229
  # guppylang-internals
230
230
 
231
- This packages contains the internals of the Guppy compiler.
231
+ This packages contains the internals of the Guppy compiler.
232
232
 
233
233
  See `guppylang` for the package providing the user-facing language frontend.
234
234
 
@@ -1,6 +1,6 @@
1
1
  # guppylang-internals
2
2
 
3
- This packages contains the internals of the Guppy compiler.
3
+ This packages contains the internals of the Guppy compiler.
4
4
 
5
5
  See `guppylang` for the package providing the user-facing language frontend.
6
6
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "guppylang-internals"
3
- version = "0.23.0"
3
+ version = "0.25.0"
4
4
  requires-python = ">=3.10,<4"
5
5
  description = "Compiler internals for `guppylang` package."
6
6
  license = { file = "LICENCE" }
@@ -34,8 +34,8 @@ classifiers = [
34
34
 
35
35
  dependencies = [
36
36
  "typing-extensions >=4.9.0,<5",
37
- "tket-exts ~= 0.10.0",
38
- "hugr ~= 0.13.1",
37
+ "tket-exts ~= 0.12.0",
38
+ "hugr ~= 0.14.1",
39
39
  ]
40
40
 
41
41
  [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.23.0"
3
+ __version__ = "0.25.0"
@@ -106,6 +106,14 @@ def return_nodes_in_ast(node: Any) -> list[ast.Return]:
106
106
  return cast(list[ast.Return], found)
107
107
 
108
108
 
109
+ def loop_in_ast(node: Any) -> list[ast.For | ast.While]:
110
+ """Returns all `For` and `While` nodes occurring in an AST."""
111
+ found = find_nodes(
112
+ lambda n: isinstance(n, ast.For | ast.While), node, {ast.FunctionDef}
113
+ )
114
+ return cast(list[ast.For | ast.While], found)
115
+
116
+
109
117
  def breaks_in_loop(node: Any) -> list[ast.Break]:
110
118
  """Returns all `Break` nodes occurring in a loop.
111
119
 
@@ -117,6 +125,19 @@ def breaks_in_loop(node: Any) -> list[ast.Break]:
117
125
  return cast(list[ast.Break], found)
118
126
 
119
127
 
128
+ def loop_controls_in_loop(node: Any) -> list[ast.Break | ast.Continue]:
129
+ """Returns all `Break` and `Continue` nodes occurring in a loop.
130
+
131
+ Note that breaks in nested loops are excluded.
132
+ """
133
+ found = find_nodes(
134
+ lambda n: isinstance(n, ast.Break | ast.Continue),
135
+ node,
136
+ {ast.For, ast.While, ast.FunctionDef},
137
+ )
138
+ return cast(list[ast.Break | ast.Continue], found)
139
+
140
+
120
141
  class ContextAdjuster(ast.NodeTransformer):
121
142
  """Updates the `ast.Context` indicating if expressions occur on the LHS or RHS."""
122
143
 
@@ -13,6 +13,7 @@ from guppylang_internals.nodes import (
13
13
  DesugaredGenerator,
14
14
  DesugaredGeneratorExpr,
15
15
  DesugaredListComp,
16
+ ModifiedBlock,
16
17
  NestedFunctionDef,
17
18
  )
18
19
 
@@ -44,6 +45,7 @@ BBStatement = (
44
45
  | ast.Expr
45
46
  | ast.Return
46
47
  | NestedFunctionDef
48
+ | ModifiedBlock
47
49
  )
48
50
 
49
51
 
@@ -219,3 +221,21 @@ class VariableVisitor(ast.NodeVisitor):
219
221
 
220
222
  # The name of the function is now assigned
221
223
  self.stats.assigned[node.name] = node
224
+
225
+ def visit_ModifiedBlock(self, node: ModifiedBlock) -> None:
226
+ for item in node.control:
227
+ self.visit(item)
228
+ for item in node.power:
229
+ self.visit(item)
230
+
231
+ # Similarly to nested functions
232
+ from guppylang_internals.cfg.analysis import LivenessAnalysis
233
+
234
+ stats = {bb: bb.compute_variable_stats() for bb in node.cfg.bbs}
235
+ live = LivenessAnalysis(stats).run(node.cfg.bbs)
236
+ assigned_before_in_bb = self.stats.assigned.keys()
237
+ self.stats.used |= {
238
+ x: using_bb.vars.used[x]
239
+ for x, using_bb in live[node.cfg.entry_bb].items()
240
+ if x not in assigned_before_in_bb
241
+ }
@@ -9,6 +9,8 @@ from guppylang_internals.ast_util import (
9
9
  AstVisitor,
10
10
  ContextAdjuster,
11
11
  find_nodes,
12
+ loop_controls_in_loop,
13
+ return_nodes_in_ast,
12
14
  set_location_from,
13
15
  template_replace,
14
16
  with_loc,
@@ -16,19 +18,34 @@ from guppylang_internals.ast_util import (
16
18
  from guppylang_internals.cfg.bb import BB, BBStatement
17
19
  from guppylang_internals.cfg.cfg import CFG
18
20
  from guppylang_internals.checker.core import Globals
19
- from guppylang_internals.checker.errors.generic import ExpectedError, UnsupportedError
21
+ from guppylang_internals.checker.errors.generic import (
22
+ ExpectedError,
23
+ UnexpectedInWithBlockError,
24
+ UnknownModifierError,
25
+ UnsupportedError,
26
+ )
27
+ from guppylang_internals.checker.errors.type_errors import WrongNumberOfArgsError
20
28
  from guppylang_internals.diagnostic import Error
21
29
  from guppylang_internals.error import GuppyError, InternalGuppyError
22
- from guppylang_internals.experimental import check_lists_enabled
30
+ from guppylang_internals.experimental import (
31
+ check_lists_enabled,
32
+ check_modifiers_enabled,
33
+ )
23
34
  from guppylang_internals.nodes import (
24
35
  ComptimeExpr,
36
+ Control,
37
+ Dagger,
25
38
  DesugaredGenerator,
26
39
  DesugaredGeneratorExpr,
27
40
  DesugaredListComp,
28
41
  IterNext,
29
42
  MakeIter,
43
+ ModifiedBlock,
44
+ Modifier,
30
45
  NestedFunctionDef,
46
+ Power,
31
47
  )
48
+ from guppylang_internals.span import Span, to_span
32
49
  from guppylang_internals.tys.ty import NoneType
33
50
 
34
51
  # In order to build expressions, need an endless stream of unique temporary variables
@@ -135,7 +152,10 @@ class CFGBuilder(AstVisitor[BB | None]):
135
152
  Builds the expression and mutates `node.value` to point to the built expression.
136
153
  Returns the BB in which the expression is available and adds the node to it.
137
154
  """
138
- if not isinstance(node, NestedFunctionDef) and node.value is not None:
155
+ if (
156
+ not isinstance(node, NestedFunctionDef | ModifiedBlock)
157
+ and node.value is not None
158
+ ):
139
159
  node.value, bb = ExprBuilder.build(node.value, self.cfg, bb)
140
160
  bb.statements.append(node)
141
161
  return bb
@@ -265,6 +285,84 @@ class CFGBuilder(AstVisitor[BB | None]):
265
285
  bb.statements.append(new_node)
266
286
  return bb
267
287
 
288
+ def visit_With(self, node: ast.With, bb: BB, jumps: Jumps) -> BB | None:
289
+ check_modifiers_enabled(node)
290
+ self._validate_modified_block(node)
291
+
292
+ cfg = CFGBuilder().build(node.body, True, self.globals)
293
+ new_node = ModifiedBlock(
294
+ cfg=cfg,
295
+ **dict(ast.iter_fields(node)),
296
+ )
297
+
298
+ for item in node.items:
299
+ item.context_expr, bb = ExprBuilder.build(item.context_expr, self.cfg, bb)
300
+ modifier = self._handle_withitem(item)
301
+ new_node.push_modifier(modifier)
302
+
303
+ set_location_from(new_node, node)
304
+ bb.statements.append(new_node)
305
+ return bb
306
+
307
+ def _handle_withitem(self, node: ast.withitem) -> Modifier:
308
+ # Check that `as` notation is not used
309
+ if node.optional_vars is not None:
310
+ span = Span(
311
+ to_span(node.context_expr).start, to_span(node.optional_vars).end
312
+ )
313
+ raise GuppyError(UnsupportedError(span, "`as` expression", singular=True))
314
+
315
+ e = node.context_expr
316
+ modifier: Modifier
317
+ match e:
318
+ case ast.Name(id="dagger"):
319
+ modifier = Dagger(e)
320
+ case ast.Call(func=ast.Name(id="dagger")):
321
+ if len(e.args) != 0:
322
+ span = Span(to_span(e.args[0]).start, to_span(e.args[-1]).end)
323
+ raise GuppyError(WrongNumberOfArgsError(span, 0, len(e.args)))
324
+ modifier = Dagger(e)
325
+ case ast.Call(func=ast.Name(id="control")):
326
+ if len(e.args) == 0:
327
+ span = Span(to_span(e.func).end, to_span(e).end)
328
+ raise GuppyError(WrongNumberOfArgsError(span, 1, len(e.args)))
329
+ modifier = Control(e, e.args)
330
+ case ast.Call(func=ast.Name(id="power")):
331
+ if len(e.args) == 0:
332
+ span = Span(to_span(e.func).end, to_span(e).end)
333
+ raise GuppyError(WrongNumberOfArgsError(span, 1, len(e.args)))
334
+ elif len(e.args) != 1:
335
+ span = Span(to_span(e.args[1]).start, to_span(e.args[-1]).end)
336
+ raise GuppyError(WrongNumberOfArgsError(span, 1, len(e.args)))
337
+ modifier = Power(e, e.args[0])
338
+ case _:
339
+ raise GuppyError(UnknownModifierError(e))
340
+ return modifier
341
+
342
+ def _validate_modified_block(self, node: ast.With) -> None:
343
+ # Check if the body contains a return statement.
344
+ return_in_body = return_nodes_in_ast(node)
345
+ if len(return_in_body) != 0:
346
+ err = UnexpectedInWithBlockError(return_in_body[0], "return", "Return")
347
+ span = Span(
348
+ to_span(node.items[0].context_expr).start,
349
+ to_span(node.items[-1].context_expr).end,
350
+ )
351
+ err.add_sub_diagnostic(UnexpectedInWithBlockError.Modifier(span))
352
+ raise GuppyError(err)
353
+
354
+ loop_controls_in_body = loop_controls_in_loop(node)
355
+ if len(loop_controls_in_body) != 0:
356
+ lc = loop_controls_in_body[0]
357
+ kind = lc.__class__.__name__
358
+ err = UnexpectedInWithBlockError(lc, "loop control", kind)
359
+ span = Span(
360
+ to_span(node.items[0].context_expr).start,
361
+ to_span(node.items[-1].context_expr).end,
362
+ )
363
+ err.add_sub_diagnostic(UnexpectedInWithBlockError.Modifier(span))
364
+ raise GuppyError(err)
365
+
268
366
  def generic_visit(self, node: ast.AST, bb: BB, jumps: Jumps) -> BB | None:
269
367
  # When adding support for new statements, we have to remember to use the
270
368
  # ExprBuilder to transform all included expressions!
@@ -54,6 +54,7 @@ from guppylang_internals.tys.ty import (
54
54
 
55
55
  if TYPE_CHECKING:
56
56
  from guppylang_internals.definition.struct import StructField
57
+ from guppylang_internals.tys.parsing import TypeParsingCtx
57
58
 
58
59
 
59
60
  #: A "place" is a description for a storage location of a local value that users
@@ -116,6 +117,10 @@ class Variable:
116
117
  """Returns a new `Variable` instance with an updated definition location."""
117
118
  return replace(self, defined_at=node)
118
119
 
120
+ def add_flags(self, flags: InputFlags) -> "Variable":
121
+ """Returns a new `Variable` instance with updated flags."""
122
+ return replace(self, flags=self.flags | flags)
123
+
119
124
 
120
125
  @dataclass(frozen=True, kw_only=True)
121
126
  class ComptimeVariable(Variable):
@@ -507,6 +512,13 @@ class Context(NamedTuple):
507
512
  locals: Locals[str, Variable]
508
513
  generic_params: dict[str, Parameter]
509
514
 
515
+ @property
516
+ def parsing_ctx(self) -> "TypeParsingCtx":
517
+ """A type parsing context derived from this checking context."""
518
+ from guppylang_internals.tys.parsing import TypeParsingCtx
519
+
520
+ return TypeParsingCtx(self.globals, self.generic_params)
521
+
510
522
 
511
523
  class DummyEvalDict(dict[str, Any]):
512
524
  """A custom dict that can be passed to `eval` to give better error messages.
@@ -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
 
6
6
 
7
7
  @dataclass(frozen=True)
@@ -43,3 +43,34 @@ class ExpectedError(Error):
43
43
  @property
44
44
  def extra(self) -> str:
45
45
  return f", got {self.got}" if self.got else ""
46
+
47
+
48
+ @dataclass(frozen=True)
49
+ class UnknownModifierError(Error):
50
+ title: ClassVar[str] = "Unknown modifier"
51
+ span_label: ClassVar[str] = (
52
+ "Expected one of {{dagger, control(...), or power(...)}}"
53
+ )
54
+
55
+
56
+ @dataclass(frozen=True)
57
+ class UnexpectedInWithBlockError(Error):
58
+ title: ClassVar[str] = "Unexpected {kind}"
59
+ span_label: ClassVar[str] = "{things} found in a `With` block"
60
+ kind: str
61
+ things: str
62
+
63
+ @dataclass(frozen=True)
64
+ class Modifier(Note):
65
+ span_label: ClassVar[str] = "modifier is used here"
66
+
67
+
68
+ @dataclass(frozen=True)
69
+ class InvalidUnderDagger(Error):
70
+ title: ClassVar[str] = "Invalid expression in dagger"
71
+ span_label: ClassVar[str] = "{things} found in a dagger context"
72
+ things: str
73
+
74
+ @dataclass(frozen=True)
75
+ class Dagger(Note):
76
+ span_label: ClassVar[str] = "dagger modifier is used here"
@@ -95,6 +95,20 @@ class TypeInferenceError(Error):
95
95
  unsolved_ty: Type
96
96
 
97
97
 
98
+ @dataclass(frozen=True)
99
+ class ParameterInferenceError(Error):
100
+ title: ClassVar[str] = "Cannot infer generic parameter"
101
+ span_label: ClassVar[str] = (
102
+ "Cannot infer generic parameter `{param}` of this function"
103
+ )
104
+ param: str
105
+
106
+ @dataclass(frozen=True)
107
+ class SignatureHint(Note):
108
+ message: ClassVar[str] = "Function signature is `{sig}`"
109
+ sig: FunctionType
110
+
111
+
98
112
  @dataclass(frozen=True)
99
113
  class IllegalConstant(Error):
100
114
  title: ClassVar[str] = "Unsupported constant"