guppylang-internals 0.25.0__tar.gz → 0.27.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.27.0/CHANGELOG.md +191 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/PKG-INFO +5 -4
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/README.md +2 -2
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/pyproject.toml +3 -2
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/__init__.py +1 -1
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/cfg/builder.py +20 -2
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/cfg/cfg.py +3 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/cfg_checker.py +6 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/core.py +1 -2
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/errors/linearity.py +6 -2
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/errors/wasm.py +7 -4
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/expr_checker.py +39 -19
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/func_checker.py +17 -13
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/linearity_checker.py +2 -10
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/modifier_checker.py +6 -2
- guppylang_internals-0.27.0/src/guppylang_internals/checker/unitary_checker.py +132 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/compiler/cfg_compiler.py +7 -6
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/compiler/core.py +5 -5
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/compiler/expr_compiler.py +72 -81
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/compiler/modifier_compiler.py +5 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/decorator.py +88 -7
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/custom.py +4 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/declaration.py +6 -2
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/function.py +26 -3
- guppylang_internals-0.27.0/src/guppylang_internals/definition/metadata.py +87 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/overloaded.py +11 -2
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/pytket_circuits.py +7 -2
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/struct.py +6 -3
- guppylang_internals-0.27.0/src/guppylang_internals/definition/wasm.py +93 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/diagnostic.py +72 -15
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/engine.py +10 -13
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/nodes.py +55 -24
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/checker.py +13 -108
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/array.py +37 -2
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/either.py +14 -2
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/list.py +1 -1
- guppylang_internals-0.27.0/src/guppylang_internals/std/_internal/compiler/platform.py +153 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/prelude.py +12 -4
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/tket_bool.py +1 -6
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/tket_exts.py +4 -5
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/debug.py +18 -9
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/util.py +1 -1
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tracing/object.py +14 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tys/errors.py +23 -1
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tys/parsing.py +3 -3
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tys/printing.py +2 -8
- guppylang_internals-0.27.0/src/guppylang_internals/tys/qubit.py +62 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tys/ty.py +60 -64
- guppylang_internals-0.27.0/src/guppylang_internals/wasm_util.py +129 -0
- guppylang_internals-0.25.0/CHANGELOG.md +0 -123
- guppylang_internals-0.25.0/src/guppylang_internals/definition/wasm.py +0 -61
- guppylang_internals-0.25.0/src/guppylang_internals/tys/qubit.py +0 -27
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/.gitignore +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/LICENCE +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/ast_util.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/cfg/__init__.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/cfg/analysis.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/cfg/bb.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/__init__.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/errors/__init__.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/errors/comptime_errors.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/errors/generic.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/errors/type_errors.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/checker/stmt_checker.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/compiler/__init__.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/compiler/func_compiler.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/compiler/hugr_extension.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/compiler/qtm_platform_extension.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/compiler/stmt_compiler.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/__init__.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/common.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/const.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/extern.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/parameter.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/traced.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/ty.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/definition/value.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/dummy_decorator.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/error.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/experimental.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/ipython_inspect.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/py.typed +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/span.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/__init__.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/__init__.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/__init__.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/arithmetic.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/frozenarray.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/futures.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/mem.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/option.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/qsystem.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/quantum.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler/wasm.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/std/_internal/compiler.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tracing/__init__.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tracing/builtins_mock.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tracing/frozenlist.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tracing/function.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tracing/state.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tracing/unpacking.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tracing/util.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tys/__init__.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tys/arg.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tys/builtin.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tys/common.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tys/const.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tys/param.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tys/subst.py +0 -0
- {guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/tys/var.py +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
First release of `guppylang_internals` package containing refactored out internal components
|
|
4
|
+
from `guppylang`.
|
|
5
|
+
|
|
6
|
+
## [0.27.0](https://github.com/Quantinuum/guppylang/compare/guppylang-internals-v0.26.0...guppylang-internals-v0.27.0) (2026-01-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* The first argument to `add_unitarity_metadata` is now named `node`
|
|
12
|
+
instead of `func`, since its type was raised to allow for more HUGR
|
|
13
|
+
nodes to be fed. Migration is trivial.
|
|
14
|
+
* `DiagnosticsRenderer.PREFIX_CONTEXT_LINES` constant has been removed.
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* Add qubit hints on Guppy functions, allowing elision when building emulators ([#1378](https://github.com/Quantinuum/guppylang/issues/1378)) ([b7f10c6](https://github.com/Quantinuum/guppylang/commit/b7f10c6798aa20841fae844084d8a1606661fd7b)), closes [#1297](https://github.com/Quantinuum/guppylang/issues/1297)
|
|
19
|
+
* Add unsafe array take and put operations ([#1165](https://github.com/Quantinuum/guppylang/issues/1165)) ([7f342e7](https://github.com/Quantinuum/guppylang/commit/7f342e788e2f179382bab46dcc7e69a24dd64de3))
|
|
20
|
+
* **internals:** update to hugr-py 0.15 ([#1418](https://github.com/Quantinuum/guppylang/issues/1418)) ([cf970ba](https://github.com/Quantinuum/guppylang/commit/cf970ba7403a126fbd5d2fd53445e65270581df4))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* Add a line break for printing WASM files ([#1386](https://github.com/Quantinuum/guppylang/issues/1386)) ([495aba5](https://github.com/Quantinuum/guppylang/commit/495aba5b9bb2218224193c7b2da2c5586744505a))
|
|
26
|
+
* added deepcopy in `OverloadedFunctionDef.{check_call,synthesize_call}` ([#1426](https://github.com/Quantinuum/guppylang/issues/1426)) ([9be6fef](https://github.com/Quantinuum/guppylang/commit/9be6fefcdfb9fc9eb1025774d2dd2727b3e719b1))
|
|
27
|
+
* **checker:** handle imported ParamDef with aliases in expr_checker ([#1385](https://github.com/Quantinuum/guppylang/issues/1385)) ([f2838a3](https://github.com/Quantinuum/guppylang/commit/f2838a34a315599c5b46eae92b72e9758e428a16))
|
|
28
|
+
* Convert symbolic pytket circuits angle inputs into rotations ([#1425](https://github.com/Quantinuum/guppylang/issues/1425)) ([4724d90](https://github.com/Quantinuum/guppylang/commit/4724d9039d8dffae8fd939f62ae80ec307d8918a))
|
|
29
|
+
* Ensure errors from `[@wasm](https://github.com/wasm)_module` are rendered correctly ([#1398](https://github.com/Quantinuum/guppylang/issues/1398)) ([a6a539f](https://github.com/Quantinuum/guppylang/commit/a6a539fe07cc94f4a788fef506969e4c9027faee)), closes [#1397](https://github.com/Quantinuum/guppylang/issues/1397)
|
|
30
|
+
* Fix another wasm diagnostics rendering issue ([#1399](https://github.com/Quantinuum/guppylang/issues/1399)) ([6604175](https://github.com/Quantinuum/guppylang/commit/660417542f2b36c387e73765f8647c11cd3d1a7b))
|
|
31
|
+
* Fix Hugr generation for tuples in `Result` and `Either` ([#1395](https://github.com/Quantinuum/guppylang/issues/1395)) ([f8b0d47](https://github.com/Quantinuum/guppylang/commit/f8b0d47eb275aae3f5ba804dfeb3640c4a3baef6)), closes [#1388](https://github.com/Quantinuum/guppylang/issues/1388)
|
|
32
|
+
* improve diagnostics rendering ([#1382](https://github.com/Quantinuum/guppylang/issues/1382)) ([e7ce7f6](https://github.com/Quantinuum/guppylang/commit/e7ce7f6d1a4f2b12ff680a6e54dae96637c5fa92))
|
|
33
|
+
* Stop parsing entrypoints twice ([#1410](https://github.com/Quantinuum/guppylang/issues/1410)) ([4a167e5](https://github.com/Quantinuum/guppylang/commit/4a167e5642cedc8f47ad027ed08483caa1558830))
|
|
34
|
+
* Support comptime expressions in generic argument applications ([#1409](https://github.com/Quantinuum/guppylang/issues/1409)) ([c1aad34](https://github.com/Quantinuum/guppylang/commit/c1aad346adb15e3636e5586987422d74e36189a1)), closes [#1087](https://github.com/Quantinuum/guppylang/issues/1087)
|
|
35
|
+
|
|
36
|
+
## [0.26.0](https://github.com/Quantinuum/guppylang/compare/guppylang-internals-v0.25.0...guppylang-internals-v0.26.0) (2025-12-11)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
### ⚠ BREAKING CHANGES
|
|
40
|
+
|
|
41
|
+
* `FunctionType` constructor no longer accepts the `input_names` argument. Instead, input names should be provided as an optional argument to `FuncInput`
|
|
42
|
+
* Removed `guppylang_internals.nodes.ResultExpr` Moved `guppylang_internals.std._internal.checker.{TAG_MAX_LEN, TooLongError}` to `guppylang_internals.std._internal.compiler.platform`
|
|
43
|
+
*
|
|
44
|
+
* The `tag` field of `guppylang_internals.nodes.{ResultExpr, StateResultExpr}` has been replaced with a const `tag_value` and a `tag_expr` expression
|
|
45
|
+
* `guppylang_internals.tys.ty.SumType` has been removed
|
|
46
|
+
*
|
|
47
|
+
* `modifier_checker.check_modified_block_signature` now requires the `ModifiedBlock` as first argument
|
|
48
|
+
|
|
49
|
+
### Features
|
|
50
|
+
|
|
51
|
+
* Allow dynamic tag and signal in `panic`/`exit` ([#1327](https://github.com/Quantinuum/guppylang/issues/1327)) ([bae0da1](https://github.com/Quantinuum/guppylang/commit/bae0da1d42eea88d34c5c7bdd3d7f8a2504f1501))
|
|
52
|
+
* Unitarity annotations for functions ([#1292](https://github.com/Quantinuum/guppylang/issues/1292)) ([54dc200](https://github.com/Quantinuum/guppylang/commit/54dc200de881d065d3ee92bdc9a8ca076990d412))
|
|
53
|
+
* Validate signatures against wasm file ([#1339](https://github.com/Quantinuum/guppylang/issues/1339)) ([e57059b](https://github.com/Quantinuum/guppylang/commit/e57059b0ed61e6d76492e52d2a6f8c83f421e46b))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Bug Fixes
|
|
57
|
+
|
|
58
|
+
* Allow comptime string arguments as result tags ([#1354](https://github.com/Quantinuum/guppylang/issues/1354)) ([cdc5c68](https://github.com/Quantinuum/guppylang/commit/cdc5c680879ae160bb592212cc8ed2fe6fc9ddbe))
|
|
59
|
+
* 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)
|
|
60
|
+
* 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)
|
|
61
|
+
* 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)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### Miscellaneous Chores
|
|
65
|
+
|
|
66
|
+
* Remove `SumType` ([#1345](https://github.com/Quantinuum/guppylang/issues/1345)) ([b914dfe](https://github.com/Quantinuum/guppylang/commit/b914dfe374a6d7c2a4fe9f95d4f6e8f2ac0675e7))
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
### Code Refactoring
|
|
70
|
+
|
|
71
|
+
* 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))
|
|
72
|
+
* Store function argument names in `FuncInput` ([#1286](https://github.com/Quantinuum/guppylang/issues/1286)) ([b701840](https://github.com/Quantinuum/guppylang/commit/b70184098a65cde48c82da89ccbb4e50d1750f1d))
|
|
73
|
+
|
|
74
|
+
## [0.25.0](https://github.com/quantinuum/guppylang/compare/guppylang-internals-v0.24.0...guppylang-internals-v0.25.0) (2025-10-28)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### ⚠ BREAKING CHANGES
|
|
78
|
+
|
|
79
|
+
* (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.
|
|
80
|
+
* `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`.
|
|
81
|
+
|
|
82
|
+
### Features
|
|
83
|
+
|
|
84
|
+
* compiler for modifiers ([#1287](https://github.com/quantinuum/guppylang/issues/1287)) ([439ff1a](https://github.com/quantinuum/guppylang/commit/439ff1ae6bd872bb7a6eb5441110d2febebd1e47))
|
|
85
|
+
* modifiers in CFG and its type checker (experimental) ([#1281](https://github.com/quantinuum/guppylang/issues/1281)) ([fe85018](https://github.com/quantinuum/guppylang/commit/fe8501854507c3c43cec2f26bba75198766a4a17))
|
|
86
|
+
* Turn type parameters into dependent telescopes ([#1154](https://github.com/quantinuum/guppylang/issues/1154)) ([b56e056](https://github.com/quantinuum/guppylang/commit/b56e056a6b4795c778ed8124a09a194fb1d97dda))
|
|
87
|
+
* update hugr, tket-exts and tket ([#1305](https://github.com/quantinuum/guppylang/issues/1305)) ([6990d85](https://github.com/quantinuum/guppylang/commit/6990d850170e6901f60ef1d1e718c99349105b56))
|
|
88
|
+
* 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))
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
### Bug Fixes
|
|
92
|
+
|
|
93
|
+
* compilation of affine-bounded type variables ([#1308](https://github.com/quantinuum/guppylang/issues/1308)) ([49ecb49](https://github.com/quantinuum/guppylang/commit/49ecb497bf450d0853baec1de9c516a3804a80eb))
|
|
94
|
+
* 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)
|
|
95
|
+
* 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)
|
|
96
|
+
* 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))
|
|
97
|
+
* multiline loop arguments ([#1309](https://github.com/quantinuum/guppylang/issues/1309)) ([836ef72](https://github.com/quantinuum/guppylang/commit/836ef722d8f8bdb02c56e5f06934246a718e68d3))
|
|
98
|
+
|
|
99
|
+
## [0.24.0](https://github.com/quantinuum/guppylang/compare/guppylang-internals-v0.23.0...guppylang-internals-v0.24.0) (2025-09-19)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
### ⚠ BREAKING CHANGES
|
|
103
|
+
|
|
104
|
+
* `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`.
|
|
105
|
+
* `TypeDef`s now require a `params` field
|
|
106
|
+
* guppylang_internals.ty.parsing.parse_function_io_types replaced with parse_function_arg_annotation and check_function_arg
|
|
107
|
+
* Significant changes to the WASM decorators, types and operations
|
|
108
|
+
* Deleted `guppylang_internals.nodes.{IterHasNext, IterEnd}`
|
|
109
|
+
* guppylang_internals.tracing.unpacking.update_packed_value now returns a bool signalling whether the operation was successful.
|
|
110
|
+
* `CompilationEngine` now initialises all it's fields
|
|
111
|
+
* Calling `CompilationEngine.reset` no longer nullifies `additional_extensions`
|
|
112
|
+
* `CompilationEngine.register_extension` no longer adds duplicates to the `additional_extensions` list
|
|
113
|
+
|
|
114
|
+
### Features
|
|
115
|
+
|
|
116
|
+
* Infer type of `self` arguments ([#1192](https://github.com/quantinuum/guppylang/issues/1192)) ([51f5a2b](https://github.com/quantinuum/guppylang/commit/51f5a2b3a9b06bc4ab054f32a4d07f7395df8ff4))
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
### Bug Fixes
|
|
120
|
+
|
|
121
|
+
* 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))
|
|
122
|
+
* 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)
|
|
123
|
+
* 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))
|
|
124
|
+
* Fix `nat` constructor in comptime functions ([#1258](https://github.com/quantinuum/guppylang/issues/1258)) ([e257b6f](https://github.com/quantinuum/guppylang/commit/e257b6fc2fe3793d6d8f63feca83bf5ed6643673))
|
|
125
|
+
* 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)
|
|
126
|
+
* wasm module updates based on tested lowering ([#1230](https://github.com/quantinuum/guppylang/issues/1230)) ([657cea2](https://github.com/quantinuum/guppylang/commit/657cea27af00a9c02e8d1a3190db535bbd1e7981))
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
### Miscellaneous Chores
|
|
130
|
+
|
|
131
|
+
* Delete unused old iterator AST nodes ([#1215](https://github.com/quantinuum/guppylang/issues/1215)) ([2310897](https://github.com/quantinuum/guppylang/commit/231089750e33cf70754e5218feed64053c558c17))
|
|
132
|
+
|
|
133
|
+
## [0.23.0](https://github.com/quantinuum/guppylang/compare/guppylang-internals-v0.22.0...guppylang-internals-v0.23.0) (2025-08-19)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
### ⚠ BREAKING CHANGES
|
|
137
|
+
|
|
138
|
+
* `check_rows_match` no longer takes `globals` Deleted `GlobalShadowError` and `BranchTypeError.GlobalHint`
|
|
139
|
+
|
|
140
|
+
### Bug Fixes
|
|
141
|
+
|
|
142
|
+
* 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))
|
|
143
|
+
* Fix scoping issues with comprehensions in comptime expressions ([#1218](https://github.com/quantinuum/guppylang/issues/1218)) ([0b990e2](https://github.com/quantinuum/guppylang/commit/0b990e2b006c31352675004aec63a857f03a0793))
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
### Documentation
|
|
147
|
+
|
|
148
|
+
* use results sequence protocol for simplicity ([#1208](https://github.com/quantinuum/guppylang/issues/1208)) ([f9c1aee](https://github.com/quantinuum/guppylang/commit/f9c1aee38776c678660ede5495989ac4d75baaeb))
|
|
149
|
+
|
|
150
|
+
## [0.22.0](https://github.com/quantinuum/guppylang/compare/guppylang-internals-v0.21.2...guppylang-internals-v0.22.0) (2025-08-11)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
### ⚠ BREAKING CHANGES
|
|
154
|
+
|
|
155
|
+
* RangeChecker has been deleted.
|
|
156
|
+
|
|
157
|
+
### Features
|
|
158
|
+
|
|
159
|
+
* 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)
|
|
160
|
+
* Allow custom start and step in `range` ([#1157](https://github.com/quantinuum/guppylang/issues/1157)) ([a1b9333](https://github.com/quantinuum/guppylang/commit/a1b9333712c74270d5efaaa72f83d6b09047c068))
|
|
161
|
+
* Improve codegen for array unpacking ([#1106](https://github.com/quantinuum/guppylang/issues/1106)) ([f375097](https://github.com/quantinuum/guppylang/commit/f3750973a719b03d27668a3ae39f58c8424deffc))
|
|
162
|
+
* Insert drop ops for affine values ([#1090](https://github.com/quantinuum/guppylang/issues/1090)) ([083133e](https://github.com/quantinuum/guppylang/commit/083133e809873fce265bb78547fc3e519cb66ea1))
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
### Bug Fixes
|
|
166
|
+
|
|
167
|
+
* Fix builtins mock escaping the tracing scope ([#1161](https://github.com/quantinuum/guppylang/issues/1161)) ([a27a5c1](https://github.com/quantinuum/guppylang/commit/a27a5c19560d76e46678f846476ea86e873ac8ac))
|
|
168
|
+
|
|
169
|
+
## [0.21.1](https://github.com/quantinuum/guppylang/compare/guppylang-internals-v0.21.0...guppylang-internals-v0.21.1) (2025-08-05)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
### Bug Fixes
|
|
173
|
+
|
|
174
|
+
* **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)
|
|
175
|
+
* 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)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
### Documentation
|
|
179
|
+
|
|
180
|
+
* Fix docs build ([#1142](https://github.com/quantinuum/guppylang/issues/1142)) ([4dfd575](https://github.com/quantinuum/guppylang/commit/4dfd575bcdfdf1e2db4e61f2f406fff27e0c08f7))
|
|
181
|
+
|
|
182
|
+
## [0.21.0](https://github.com/quantinuum/guppylang/compare/guppylang-internals-v0.20.0...guppylang-internals-v0.21.0) (2025-08-04)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
### ⚠ BREAKING CHANGES
|
|
186
|
+
|
|
187
|
+
* All compiler-internal and non-userfacing functionality is moved into a new `guppylang_internals` package
|
|
188
|
+
|
|
189
|
+
### Code Refactoring
|
|
190
|
+
|
|
191
|
+
* 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.27.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.
|
|
222
|
+
Requires-Dist: hugr~=0.15.0
|
|
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/
|
|
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.27.0"
|
|
4
4
|
requires-python = ">=3.10,<4"
|
|
5
5
|
description = "Compiler internals for `guppylang` package."
|
|
6
6
|
license = { file = "LICENCE" }
|
|
@@ -35,7 +35,8 @@ classifiers = [
|
|
|
35
35
|
dependencies = [
|
|
36
36
|
"typing-extensions >=4.9.0,<5",
|
|
37
37
|
"tket-exts ~= 0.12.0",
|
|
38
|
-
"hugr ~= 0.
|
|
38
|
+
"hugr ~= 0.15.0",
|
|
39
|
+
"wasmtime ~= v38.0.0",
|
|
39
40
|
]
|
|
40
41
|
|
|
41
42
|
[project.optional-dependencies]
|
{guppylang_internals-0.25.0 → guppylang_internals-0.27.0}/src/guppylang_internals/cfg/builder.py
RENAMED
|
@@ -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(
|
|
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
|
|
@@ -653,6 +668,9 @@ def is_comptime_expression(node: ast.AST) -> ComptimeExpr | None:
|
|
|
653
668
|
|
|
654
669
|
Otherwise, returns `None`.
|
|
655
670
|
"""
|
|
671
|
+
if isinstance(node, ComptimeExpr):
|
|
672
|
+
return node
|
|
673
|
+
|
|
656
674
|
if (
|
|
657
675
|
isinstance(node, ast.Call)
|
|
658
676
|
and isinstance(node.func, ast.Name)
|
{guppylang_internals-0.25.0 → guppylang_internals-0.27.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.25.0 → guppylang_internals-0.27.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
|
)
|
|
@@ -360,7 +359,7 @@ class Globals:
|
|
|
360
359
|
match ty:
|
|
361
360
|
case TypeDef() as type_defn:
|
|
362
361
|
pass
|
|
363
|
-
case BoundTypeVar() | ExistentialTypeVar()
|
|
362
|
+
case BoundTypeVar() | ExistentialTypeVar():
|
|
364
363
|
return None
|
|
365
364
|
case NumericType(kind):
|
|
366
365
|
match kind:
|
|
@@ -33,7 +33,9 @@ class AlreadyUsedError(Error):
|
|
|
33
33
|
|
|
34
34
|
@dataclass(frozen=True)
|
|
35
35
|
class PrevUse(Note):
|
|
36
|
-
span_label: ClassVar[str] =
|
|
36
|
+
span_label: ClassVar[str] = (
|
|
37
|
+
"{place.describe} already {prev_kind.subjunctive} here"
|
|
38
|
+
)
|
|
37
39
|
prev_kind: UseKind
|
|
38
40
|
|
|
39
41
|
@dataclass(frozen=True)
|
|
@@ -55,7 +57,9 @@ class ComprAlreadyUsedError(Error):
|
|
|
55
57
|
|
|
56
58
|
@dataclass(frozen=True)
|
|
57
59
|
class PrevUse(Note):
|
|
58
|
-
span_label: ClassVar[str] =
|
|
60
|
+
span_label: ClassVar[str] = (
|
|
61
|
+
"{place.describe} already {prev_kind.subjunctive} here"
|
|
62
|
+
)
|
|
59
63
|
prev_kind: UseKind
|
|
60
64
|
|
|
61
65
|
|
|
@@ -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)
|
|
@@ -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,
|
|
@@ -84,6 +85,7 @@ from guppylang_internals.checker.errors.type_errors import (
|
|
|
84
85
|
WrongNumberOfArgsError,
|
|
85
86
|
)
|
|
86
87
|
from guppylang_internals.definition.common import Definition
|
|
88
|
+
from guppylang_internals.definition.parameter import ParamDef
|
|
87
89
|
from guppylang_internals.definition.ty import TypeDef
|
|
88
90
|
from guppylang_internals.definition.value import CallableDef, ValueDef
|
|
89
91
|
from guppylang_internals.error import (
|
|
@@ -406,23 +408,27 @@ class ExprSynthesizer(AstVisitor[tuple[ast.expr, Type]]):
|
|
|
406
408
|
raise GuppyError(IllegalConstant(node, type(node.value)))
|
|
407
409
|
return node, ty
|
|
408
410
|
|
|
411
|
+
def _check_generic_param(self, name: str, node: ast.expr) -> tuple[ast.expr, Type]:
|
|
412
|
+
"""Helper method to check a generic parameter (ConstParam or TypeParam)."""
|
|
413
|
+
param = self.ctx.generic_params[name]
|
|
414
|
+
match param:
|
|
415
|
+
case ConstParam() as param:
|
|
416
|
+
ast_node = with_loc(node, GenericParamValue(id=name, param=param))
|
|
417
|
+
return ast_node, param.ty
|
|
418
|
+
case TypeParam() as param:
|
|
419
|
+
raise GuppyError(
|
|
420
|
+
ExpectedError(node, "a value", got=f"type `{param.name}`")
|
|
421
|
+
)
|
|
422
|
+
case _:
|
|
423
|
+
return assert_never(param)
|
|
424
|
+
|
|
409
425
|
def visit_Name(self, node: ast.Name) -> tuple[ast.expr, Type]:
|
|
410
426
|
x = node.id
|
|
411
427
|
if x in self.ctx.locals:
|
|
412
428
|
var = self.ctx.locals[x]
|
|
413
429
|
return with_loc(node, PlaceNode(place=var)), var.ty
|
|
414
430
|
elif x in self.ctx.generic_params:
|
|
415
|
-
|
|
416
|
-
match param:
|
|
417
|
-
case ConstParam() as param:
|
|
418
|
-
ast_node = with_loc(node, GenericParamValue(id=x, param=param))
|
|
419
|
-
return ast_node, param.ty
|
|
420
|
-
case TypeParam() as param:
|
|
421
|
-
raise GuppyError(
|
|
422
|
-
ExpectedError(node, "a value", got=f"type `{param.name}`")
|
|
423
|
-
)
|
|
424
|
-
case _:
|
|
425
|
-
return assert_never(param)
|
|
431
|
+
return self._check_generic_param(x, node)
|
|
426
432
|
elif x in self.ctx.globals:
|
|
427
433
|
match self.ctx.globals[x]:
|
|
428
434
|
case Definition() as defn:
|
|
@@ -453,6 +459,16 @@ class ExprSynthesizer(AstVisitor[tuple[ast.expr, Type]]):
|
|
|
453
459
|
defn, "__new__"
|
|
454
460
|
):
|
|
455
461
|
return with_loc(node, GlobalName(id=name, def_id=constr.id)), constr.ty
|
|
462
|
+
# Handle parameter definitions (e.g., nat_var) that may be imported
|
|
463
|
+
case ParamDef():
|
|
464
|
+
# Check if this parameter is in our generic_params
|
|
465
|
+
# (e.g., used in type signature)
|
|
466
|
+
if name in self.ctx.generic_params:
|
|
467
|
+
return self._check_generic_param(name, node)
|
|
468
|
+
# If not in generic_params, it's being used outside its scope
|
|
469
|
+
raise GuppyError(
|
|
470
|
+
ExpectedError(node, "a value", got=f"{defn.description} `{name}`")
|
|
471
|
+
)
|
|
456
472
|
case defn:
|
|
457
473
|
raise GuppyError(
|
|
458
474
|
ExpectedError(node, "a value", got=f"{defn.description} `{name}`")
|
|
@@ -468,7 +484,7 @@ class ExprSynthesizer(AstVisitor[tuple[ast.expr, Type]]):
|
|
|
468
484
|
# The only exception are attributes accesses that are generated during
|
|
469
485
|
# desugaring (for example for iterators in `for` loops). Since those just
|
|
470
486
|
# inherit the span of the sugared code, we could have line breaks there.
|
|
471
|
-
# See https://github.com/
|
|
487
|
+
# See https://github.com/quantinuum/guppylang/issues/1301
|
|
472
488
|
span = to_span(node)
|
|
473
489
|
if span.start.line == span.end.line:
|
|
474
490
|
attr_span = Span(span.end.shift_left(len(node.attr)), span.end)
|
|
@@ -503,12 +519,7 @@ class ExprSynthesizer(AstVisitor[tuple[ast.expr, Type]]):
|
|
|
503
519
|
)
|
|
504
520
|
# Make a closure by partially applying the `self` argument
|
|
505
521
|
# 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
|
-
)
|
|
522
|
+
result_ty = FunctionType(func.ty.inputs[1:], func.ty.output, func.ty.params)
|
|
512
523
|
return with_loc(node, PartialApply(func=name, args=[node.value])), result_ty
|
|
513
524
|
raise GuppyTypeError(AttributeNotFoundError(attr_span, ty, node.attr))
|
|
514
525
|
|
|
@@ -1035,7 +1046,14 @@ def check_place_assignable(
|
|
|
1035
1046
|
exp_sig = FunctionType(
|
|
1036
1047
|
[
|
|
1037
1048
|
FuncInput(parent.ty, InputFlags.Inout),
|
|
1038
|
-
FuncInput(
|
|
1049
|
+
FuncInput(
|
|
1050
|
+
# Due to potential coercions that were applied during the
|
|
1051
|
+
# `__getitem__` call (e.g. coercing a nat index to int), we're
|
|
1052
|
+
# not allowed to rely on `item.ty` here.
|
|
1053
|
+
# See https://github.com/CQCL/guppylang/issues/1356
|
|
1054
|
+
ExistentialTypeVar.fresh("T", True, True),
|
|
1055
|
+
InputFlags.NoFlags,
|
|
1056
|
+
),
|
|
1039
1057
|
FuncInput(ty, InputFlags.Owned),
|
|
1040
1058
|
],
|
|
1041
1059
|
NoneType(),
|
|
@@ -1072,6 +1090,8 @@ def check_comptime_arg(
|
|
|
1072
1090
|
match arg:
|
|
1073
1091
|
case ast.Constant(value=v):
|
|
1074
1092
|
const = ConstValue(ty, v)
|
|
1093
|
+
case PlaceNode(place=ComptimeVariable(ty=ty, static_value=v)):
|
|
1094
|
+
const = ConstValue(ty, v)
|
|
1075
1095
|
case GenericParamValue(param=const_param):
|
|
1076
1096
|
const = const_param.to_bound().const
|
|
1077
1097
|
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
|
|
139
|
+
assert all(inp.name is not None for inp in ty.inputs)
|
|
138
140
|
|
|
139
|
-
|
|
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(
|
|
142
|
-
for
|
|
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,
|
|
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(
|
|
198
|
-
for
|
|
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,
|
|
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
|
|