guppylang-internals 0.24.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.
- guppylang_internals-0.26.0/CHANGELOG.md +161 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/PKG-INFO +6 -5
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/README.md +2 -2
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/pyproject.toml +4 -3
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/__init__.py +1 -1
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/ast_util.py +21 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/cfg/bb.py +20 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/cfg/builder.py +118 -5
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/cfg/cfg.py +3 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/cfg_checker.py +6 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/core.py +5 -2
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/errors/generic.py +32 -1
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/errors/type_errors.py +14 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/errors/wasm.py +7 -4
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/expr_checker.py +58 -17
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/func_checker.py +18 -14
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/linearity_checker.py +67 -10
- guppylang_internals-0.26.0/src/guppylang_internals/checker/modifier_checker.py +120 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/stmt_checker.py +48 -1
- guppylang_internals-0.26.0/src/guppylang_internals/checker/unitary_checker.py +132 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/cfg_compiler.py +7 -6
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/core.py +93 -56
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/expr_compiler.py +72 -168
- guppylang_internals-0.26.0/src/guppylang_internals/compiler/modifier_compiler.py +176 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/stmt_compiler.py +15 -8
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/decorator.py +86 -7
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/custom.py +39 -1
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/declaration.py +9 -6
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/function.py +12 -2
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/parameter.py +8 -3
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/pytket_circuits.py +14 -41
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/struct.py +13 -7
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/ty.py +3 -3
- guppylang_internals-0.26.0/src/guppylang_internals/definition/wasm.py +93 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/engine.py +9 -3
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/experimental.py +5 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/nodes.py +147 -24
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/checker.py +13 -108
- guppylang_internals-0.26.0/src/guppylang_internals/std/_internal/compiler/array.py +381 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/list.py +1 -1
- guppylang_internals-0.26.0/src/guppylang_internals/std/_internal/compiler/platform.py +153 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/prelude.py +12 -4
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/tket_exts.py +8 -2
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/debug.py +18 -9
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/util.py +1 -1
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/object.py +10 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/unpacking.py +19 -20
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/arg.py +18 -3
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/builtin.py +2 -5
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/const.py +33 -4
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/errors.py +23 -1
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/param.py +31 -16
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/parsing.py +11 -24
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/printing.py +2 -8
- guppylang_internals-0.26.0/src/guppylang_internals/tys/qubit.py +62 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/subst.py +8 -26
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/ty.py +91 -85
- guppylang_internals-0.26.0/src/guppylang_internals/wasm_util.py +129 -0
- guppylang_internals-0.24.0/CHANGELOG.md +0 -98
- guppylang_internals-0.24.0/src/guppylang_internals/definition/wasm.py +0 -61
- guppylang_internals-0.24.0/src/guppylang_internals/std/_internal/compiler/array.py +0 -569
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/.gitignore +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/LICENCE +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/cfg/__init__.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/cfg/analysis.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/__init__.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/errors/__init__.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/errors/comptime_errors.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/errors/linearity.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/__init__.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/func_compiler.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/hugr_extension.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/compiler/qtm_platform_extension.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/__init__.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/common.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/const.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/extern.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/overloaded.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/traced.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/definition/value.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/diagnostic.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/dummy_decorator.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/error.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/ipython_inspect.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/py.typed +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/span.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/__init__.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/__init__.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/__init__.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/arithmetic.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/either.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/frozenarray.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/futures.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/mem.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/option.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/qsystem.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/quantum.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/tket_bool.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler/wasm.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/std/_internal/compiler.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/__init__.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/builtins_mock.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/frozenlist.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/function.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/state.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tracing/util.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/__init__.py +0 -0
- {guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/tys/common.py +0 -0
- {guppylang_internals-0.24.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.
|
|
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>
|
|
@@ -219,9 +219,10 @@ 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.
|
|
223
|
-
Requires-Dist: tket-exts~=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
|
+
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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.
|
|
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" }
|
|
@@ -34,8 +34,9 @@ classifiers = [
|
|
|
34
34
|
|
|
35
35
|
dependencies = [
|
|
36
36
|
"typing-extensions >=4.9.0,<5",
|
|
37
|
-
"tket-exts ~= 0.
|
|
38
|
-
"hugr ~= 0.
|
|
37
|
+
"tket-exts ~= 0.12.0",
|
|
38
|
+
"hugr ~= 0.14.1",
|
|
39
|
+
"wasmtime ~= v38.0.0",
|
|
39
40
|
]
|
|
40
41
|
|
|
41
42
|
[project.optional-dependencies]
|
{guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/ast_util.py
RENAMED
|
@@ -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
|
+
}
|
{guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/cfg/builder.py
RENAMED
|
@@ -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,20 +18,35 @@ 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
|
|
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
|
|
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
|
)
|
|
32
|
-
from guppylang_internals.
|
|
48
|
+
from guppylang_internals.span import Span, to_span
|
|
49
|
+
from guppylang_internals.tys.ty import NoneType, UnitaryFlags
|
|
33
50
|
|
|
34
51
|
# In order to build expressions, need an endless stream of unique temporary variables
|
|
35
52
|
# to store intermediate results
|
|
@@ -61,7 +78,13 @@ class CFGBuilder(AstVisitor[BB | None]):
|
|
|
61
78
|
cfg: CFG
|
|
62
79
|
globals: Globals
|
|
63
80
|
|
|
64
|
-
def build(
|
|
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:
|
|
65
88
|
"""Builds a CFG from a list of ast nodes.
|
|
66
89
|
|
|
67
90
|
We also require the expected number of return ports for the whole CFG. This is
|
|
@@ -69,6 +92,7 @@ class CFGBuilder(AstVisitor[BB | None]):
|
|
|
69
92
|
variables.
|
|
70
93
|
"""
|
|
71
94
|
self.cfg = CFG()
|
|
95
|
+
self.cfg.unitary_flags = unitary_flags
|
|
72
96
|
self.globals = globals
|
|
73
97
|
|
|
74
98
|
final_bb = self.visit_stmts(
|
|
@@ -135,7 +159,10 @@ class CFGBuilder(AstVisitor[BB | None]):
|
|
|
135
159
|
Builds the expression and mutates `node.value` to point to the built expression.
|
|
136
160
|
Returns the BB in which the expression is available and adds the node to it.
|
|
137
161
|
"""
|
|
138
|
-
if
|
|
162
|
+
if (
|
|
163
|
+
not isinstance(node, NestedFunctionDef | ModifiedBlock)
|
|
164
|
+
and node.value is not None
|
|
165
|
+
):
|
|
139
166
|
node.value, bb = ExprBuilder.build(node.value, self.cfg, bb)
|
|
140
167
|
bb.statements.append(node)
|
|
141
168
|
return bb
|
|
@@ -253,6 +280,7 @@ class CFGBuilder(AstVisitor[BB | None]):
|
|
|
253
280
|
|
|
254
281
|
func_ty = check_signature(node, self.globals)
|
|
255
282
|
returns_none = isinstance(func_ty.output, NoneType)
|
|
283
|
+
# No UnitaryFlags are assigned to nested functions
|
|
256
284
|
cfg = CFGBuilder().build(node.body, returns_none, self.globals)
|
|
257
285
|
|
|
258
286
|
new_node = NestedFunctionDef(
|
|
@@ -265,6 +293,91 @@ class CFGBuilder(AstVisitor[BB | None]):
|
|
|
265
293
|
bb.statements.append(new_node)
|
|
266
294
|
return bb
|
|
267
295
|
|
|
296
|
+
def visit_With(self, node: ast.With, bb: BB, jumps: Jumps) -> BB | None:
|
|
297
|
+
check_modifiers_enabled(node)
|
|
298
|
+
self._validate_modified_block(node)
|
|
299
|
+
|
|
300
|
+
cfg = CFGBuilder().build(node.body, True, self.globals)
|
|
301
|
+
new_node = ModifiedBlock(
|
|
302
|
+
cfg=cfg,
|
|
303
|
+
**dict(ast.iter_fields(node)),
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
for item in node.items:
|
|
307
|
+
item.context_expr, bb = ExprBuilder.build(item.context_expr, self.cfg, bb)
|
|
308
|
+
modifier = self._handle_withitem(item)
|
|
309
|
+
new_node.push_modifier(modifier)
|
|
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
|
+
|
|
318
|
+
set_location_from(new_node, node)
|
|
319
|
+
bb.statements.append(new_node)
|
|
320
|
+
return bb
|
|
321
|
+
|
|
322
|
+
def _handle_withitem(self, node: ast.withitem) -> Modifier:
|
|
323
|
+
# Check that `as` notation is not used
|
|
324
|
+
if node.optional_vars is not None:
|
|
325
|
+
span = Span(
|
|
326
|
+
to_span(node.context_expr).start, to_span(node.optional_vars).end
|
|
327
|
+
)
|
|
328
|
+
raise GuppyError(UnsupportedError(span, "`as` expression", singular=True))
|
|
329
|
+
|
|
330
|
+
e = node.context_expr
|
|
331
|
+
modifier: Modifier
|
|
332
|
+
match e:
|
|
333
|
+
case ast.Name(id="dagger"):
|
|
334
|
+
modifier = Dagger(e)
|
|
335
|
+
case ast.Call(func=ast.Name(id="dagger")):
|
|
336
|
+
if len(e.args) != 0:
|
|
337
|
+
span = Span(to_span(e.args[0]).start, to_span(e.args[-1]).end)
|
|
338
|
+
raise GuppyError(WrongNumberOfArgsError(span, 0, len(e.args)))
|
|
339
|
+
modifier = Dagger(e)
|
|
340
|
+
case ast.Call(func=ast.Name(id="control")):
|
|
341
|
+
if len(e.args) == 0:
|
|
342
|
+
span = Span(to_span(e.func).end, to_span(e).end)
|
|
343
|
+
raise GuppyError(WrongNumberOfArgsError(span, 1, len(e.args)))
|
|
344
|
+
modifier = Control(e, e.args)
|
|
345
|
+
case ast.Call(func=ast.Name(id="power")):
|
|
346
|
+
if len(e.args) == 0:
|
|
347
|
+
span = Span(to_span(e.func).end, to_span(e).end)
|
|
348
|
+
raise GuppyError(WrongNumberOfArgsError(span, 1, len(e.args)))
|
|
349
|
+
elif len(e.args) != 1:
|
|
350
|
+
span = Span(to_span(e.args[1]).start, to_span(e.args[-1]).end)
|
|
351
|
+
raise GuppyError(WrongNumberOfArgsError(span, 1, len(e.args)))
|
|
352
|
+
modifier = Power(e, e.args[0])
|
|
353
|
+
case _:
|
|
354
|
+
raise GuppyError(UnknownModifierError(e))
|
|
355
|
+
return modifier
|
|
356
|
+
|
|
357
|
+
def _validate_modified_block(self, node: ast.With) -> None:
|
|
358
|
+
# Check if the body contains a return statement.
|
|
359
|
+
return_in_body = return_nodes_in_ast(node)
|
|
360
|
+
if len(return_in_body) != 0:
|
|
361
|
+
err = UnexpectedInWithBlockError(return_in_body[0], "return", "Return")
|
|
362
|
+
span = Span(
|
|
363
|
+
to_span(node.items[0].context_expr).start,
|
|
364
|
+
to_span(node.items[-1].context_expr).end,
|
|
365
|
+
)
|
|
366
|
+
err.add_sub_diagnostic(UnexpectedInWithBlockError.Modifier(span))
|
|
367
|
+
raise GuppyError(err)
|
|
368
|
+
|
|
369
|
+
loop_controls_in_body = loop_controls_in_loop(node)
|
|
370
|
+
if len(loop_controls_in_body) != 0:
|
|
371
|
+
lc = loop_controls_in_body[0]
|
|
372
|
+
kind = lc.__class__.__name__
|
|
373
|
+
err = UnexpectedInWithBlockError(lc, "loop control", kind)
|
|
374
|
+
span = Span(
|
|
375
|
+
to_span(node.items[0].context_expr).start,
|
|
376
|
+
to_span(node.items[-1].context_expr).end,
|
|
377
|
+
)
|
|
378
|
+
err.add_sub_diagnostic(UnexpectedInWithBlockError.Modifier(span))
|
|
379
|
+
raise GuppyError(err)
|
|
380
|
+
|
|
268
381
|
def generic_visit(self, node: ast.AST, bb: BB, jumps: Jumps) -> BB | None:
|
|
269
382
|
# When adding support for new statements, we have to remember to use the
|
|
270
383
|
# ExprBuilder to transform all included expressions!
|
{guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/cfg/cfg.py
RENAMED
|
@@ -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
|
|
{guppylang_internals-0.24.0 → guppylang_internals-0.26.0}/src/guppylang_internals/checker/core.py
RENAMED
|
@@ -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
|
)
|
|
@@ -117,6 +116,10 @@ class Variable:
|
|
|
117
116
|
"""Returns a new `Variable` instance with an updated definition location."""
|
|
118
117
|
return replace(self, defined_at=node)
|
|
119
118
|
|
|
119
|
+
def add_flags(self, flags: InputFlags) -> "Variable":
|
|
120
|
+
"""Returns a new `Variable` instance with updated flags."""
|
|
121
|
+
return replace(self, flags=self.flags | flags)
|
|
122
|
+
|
|
120
123
|
|
|
121
124
|
@dataclass(frozen=True, kw_only=True)
|
|
122
125
|
class ComptimeVariable(Variable):
|
|
@@ -356,7 +359,7 @@ class Globals:
|
|
|
356
359
|
match ty:
|
|
357
360
|
case TypeDef() as type_defn:
|
|
358
361
|
pass
|
|
359
|
-
case BoundTypeVar() | ExistentialTypeVar()
|
|
362
|
+
case BoundTypeVar() | ExistentialTypeVar():
|
|
360
363
|
return None
|
|
361
364
|
case NumericType(kind):
|
|
362
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
|
|
|
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"
|
|
@@ -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
|
|
17
|
-
" Found `{ty}` instead"
|
|
16
|
+
"First argument to WASM function should be a WASM module."
|
|
18
17
|
)
|
|
19
|
-
|
|
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)
|