guppylang-internals 0.22.0__tar.gz → 0.23.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.22.0 → guppylang_internals-0.23.0}/CHANGELOG.md +17 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/PKG-INFO +3 -3
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/README.md +1 -1
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/pyproject.toml +2 -2
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/__init__.py +1 -1
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/cfg/cfg.py +8 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/cfg_checker.py +26 -65
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/expr_checker.py +1 -5
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/.gitignore +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/LICENCE +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/ast_util.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/cfg/__init__.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/cfg/analysis.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/cfg/bb.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/cfg/builder.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/__init__.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/core.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/errors/__init__.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/errors/comptime_errors.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/errors/generic.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/errors/linearity.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/errors/type_errors.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/errors/wasm.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/func_checker.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/linearity_checker.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/stmt_checker.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/compiler/__init__.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/compiler/cfg_compiler.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/compiler/core.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/compiler/expr_compiler.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/compiler/func_compiler.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/compiler/hugr_extension.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/compiler/qtm_platform_extension.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/compiler/stmt_compiler.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/decorator.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/__init__.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/common.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/const.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/custom.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/declaration.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/extern.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/function.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/overloaded.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/parameter.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/pytket_circuits.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/struct.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/traced.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/ty.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/value.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/wasm.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/diagnostic.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/dummy_decorator.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/engine.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/error.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/experimental.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/ipython_inspect.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/nodes.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/py.typed +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/span.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/__init__.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/__init__.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/checker.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/__init__.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/arithmetic.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/array.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/either.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/frozenarray.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/futures.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/list.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/mem.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/option.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/prelude.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/qsystem.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/quantum.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/tket_bool.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/tket_exts.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler/wasm.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/compiler.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/debug.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/_internal/util.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tracing/__init__.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tracing/builtins_mock.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tracing/frozenlist.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tracing/function.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tracing/object.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tracing/state.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tracing/unpacking.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tracing/util.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/__init__.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/arg.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/builtin.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/common.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/const.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/errors.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/param.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/parsing.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/printing.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/subst.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/ty.py +0 -0
- {guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/var.py +0 -0
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
First release of `guppylang_internals` package containing refactored out internal components
|
|
4
4
|
from `guppylang`.
|
|
5
5
|
|
|
6
|
+
## [0.23.0](https://github.com/CQCL/guppylang/compare/guppylang-internals-v0.22.0...guppylang-internals-v0.23.0) (2025-08-19)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* `check_rows_match` no longer takes `globals` Deleted `GlobalShadowError` and `BranchTypeError.GlobalHint`
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* Fix globals vs locals scoping behaviour to match Python ([#1169](https://github.com/CQCL/guppylang/issues/1169)) ([a6a91ca](https://github.com/CQCL/guppylang/commit/a6a91ca32ad7c67bf1d733eb26c016a2662256ef))
|
|
16
|
+
* Fix scoping issues with comprehensions in comptime expressions ([#1218](https://github.com/CQCL/guppylang/issues/1218)) ([0b990e2](https://github.com/CQCL/guppylang/commit/0b990e2b006c31352675004aec63a857f03a0793))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Documentation
|
|
20
|
+
|
|
21
|
+
* use results sequence protocol for simplicity ([#1208](https://github.com/CQCL/guppylang/issues/1208)) ([f9c1aee](https://github.com/CQCL/guppylang/commit/f9c1aee38776c678660ede5495989ac4d75baaeb))
|
|
22
|
+
|
|
6
23
|
## [0.22.0](https://github.com/CQCL/guppylang/compare/guppylang-internals-v0.21.2...guppylang-internals-v0.22.0) (2025-08-11)
|
|
7
24
|
|
|
8
25
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: guppylang-internals
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.23.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,7 +219,7 @@ 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
|
|
222
|
+
Requires-Dist: hugr~=0.13.1
|
|
223
223
|
Requires-Dist: tket-exts~=0.10.0
|
|
224
224
|
Requires-Dist: typing-extensions<5,>=4.9.0
|
|
225
225
|
Provides-Extra: pytket
|
|
@@ -250,4 +250,4 @@ See [DEVELOPMENT.md] information on how to develop and contribute to this packag
|
|
|
250
250
|
|
|
251
251
|
This project is licensed under Apache License, Version 2.0 ([LICENCE][] or http://www.apache.org/licenses/LICENSE-2.0).
|
|
252
252
|
|
|
253
|
-
[LICENCE]: https://github.com/CQCL/guppylang/blob/main/LICENCE
|
|
253
|
+
[LICENCE]: https://github.com/CQCL/guppylang/blob/main/LICENCE
|
|
@@ -22,4 +22,4 @@ See [DEVELOPMENT.md] information on how to develop and contribute to this packag
|
|
|
22
22
|
|
|
23
23
|
This project is licensed under Apache License, Version 2.0 ([LICENCE][] or http://www.apache.org/licenses/LICENSE-2.0).
|
|
24
24
|
|
|
25
|
-
[LICENCE]: https://github.com/CQCL/guppylang/blob/main/LICENCE
|
|
25
|
+
[LICENCE]: https://github.com/CQCL/guppylang/blob/main/LICENCE
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "guppylang-internals"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.23.0"
|
|
4
4
|
requires-python = ">=3.10,<4"
|
|
5
5
|
description = "Compiler internals for `guppylang` package."
|
|
6
6
|
license = { file = "LICENCE" }
|
|
@@ -35,7 +35,7 @@ classifiers = [
|
|
|
35
35
|
dependencies = [
|
|
36
36
|
"typing-extensions >=4.9.0,<5",
|
|
37
37
|
"tket-exts ~= 0.10.0",
|
|
38
|
-
"hugr
|
|
38
|
+
"hugr ~= 0.13.1",
|
|
39
39
|
]
|
|
40
40
|
|
|
41
41
|
[project.optional-dependencies]
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/cfg/cfg.py
RENAMED
|
@@ -27,6 +27,9 @@ class BaseCFG(Generic[T]):
|
|
|
27
27
|
ass_before: Result[DefAssignmentDomain[str]]
|
|
28
28
|
maybe_ass_before: Result[MaybeAssignmentDomain[str]]
|
|
29
29
|
|
|
30
|
+
#: Set of variables defined in this CFG
|
|
31
|
+
assigned_somewhere: set[str]
|
|
32
|
+
|
|
30
33
|
def __init__(
|
|
31
34
|
self, bbs: list[T], entry_bb: T | None = None, exit_bb: T | None = None
|
|
32
35
|
):
|
|
@@ -38,6 +41,7 @@ class BaseCFG(Generic[T]):
|
|
|
38
41
|
self.live_before = {}
|
|
39
42
|
self.ass_before = {}
|
|
40
43
|
self.maybe_ass_before = {}
|
|
44
|
+
self.assigned_somewhere = set()
|
|
41
45
|
|
|
42
46
|
def ancestors(self, *bbs: T) -> Iterator[T]:
|
|
43
47
|
"""Returns an iterator over all ancestors of the given BBs in BFS order."""
|
|
@@ -101,6 +105,10 @@ class CFG(BaseCFG[BB]):
|
|
|
101
105
|
inout_vars: list[str],
|
|
102
106
|
) -> dict[BB, VariableStats[str]]:
|
|
103
107
|
stats = {bb: bb.compute_variable_stats() for bb in self.bbs}
|
|
108
|
+
# Locals are variables that are assigned somewhere inside the function
|
|
109
|
+
self.assigned_somewhere = def_ass_before.union(
|
|
110
|
+
maybe_ass_before, (x for bb in self.bbs for x in stats[bb].assigned)
|
|
111
|
+
)
|
|
104
112
|
# Mark all borrowed variables as implicitly used in the exit BB
|
|
105
113
|
stats[self.exit_bb].used |= {x: InoutReturnSentinel(var=x) for x in inout_vars}
|
|
106
114
|
# This also means borrowed variables are always live, so we can use them as the
|
|
@@ -8,7 +8,7 @@ import ast
|
|
|
8
8
|
import collections
|
|
9
9
|
from collections.abc import Iterator, Sequence
|
|
10
10
|
from dataclasses import dataclass, field
|
|
11
|
-
from typing import ClassVar, Generic, TypeVar
|
|
11
|
+
from typing import ClassVar, Generic, TypeVar
|
|
12
12
|
|
|
13
13
|
from guppylang_internals.ast_util import line_col
|
|
14
14
|
from guppylang_internals.cfg.bb import BB
|
|
@@ -23,7 +23,6 @@ from guppylang_internals.checker.core import (
|
|
|
23
23
|
)
|
|
24
24
|
from guppylang_internals.checker.expr_checker import ExprSynthesizer, to_bool
|
|
25
25
|
from guppylang_internals.checker.stmt_checker import StmtChecker
|
|
26
|
-
from guppylang_internals.definition.value import ValueDef
|
|
27
26
|
from guppylang_internals.diagnostic import Error, Note
|
|
28
27
|
from guppylang_internals.error import GuppyError
|
|
29
28
|
from guppylang_internals.tys.param import Parameter
|
|
@@ -115,7 +114,7 @@ def check_cfg(
|
|
|
115
114
|
if bb in compiled:
|
|
116
115
|
# If the BB was already compiled, we just have to check that the signatures
|
|
117
116
|
# match.
|
|
118
|
-
check_rows_match(input_row, compiled[bb].sig.input_row, bb
|
|
117
|
+
check_rows_match(input_row, compiled[bb].sig.input_row, bb)
|
|
119
118
|
else:
|
|
120
119
|
# Otherwise, check the BB and enqueue its successors
|
|
121
120
|
checked_bb = check_bb(
|
|
@@ -195,21 +194,6 @@ class BranchTypeError(Error):
|
|
|
195
194
|
span_label: ClassVar[str] = "This is of type `{ty}`"
|
|
196
195
|
ty: Type
|
|
197
196
|
|
|
198
|
-
@dataclass(frozen=True)
|
|
199
|
-
class GlobalHint(Note):
|
|
200
|
-
message: ClassVar[str] = (
|
|
201
|
-
"{ident} may be shadowing a global {defn.description} definition of type "
|
|
202
|
-
"`{defn.ty}` on some branches"
|
|
203
|
-
)
|
|
204
|
-
defn: ValueDef
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
@dataclass(frozen=True)
|
|
208
|
-
class GlobalShadowError(Error):
|
|
209
|
-
title: ClassVar[str] = "Global variable conditionally shadowed"
|
|
210
|
-
span_label: ClassVar[str] = "{ident} may be shadowing a global variable"
|
|
211
|
-
ident: str
|
|
212
|
-
|
|
213
197
|
|
|
214
198
|
def check_bb(
|
|
215
199
|
bb: BB,
|
|
@@ -245,23 +229,27 @@ def check_bb(
|
|
|
245
229
|
|
|
246
230
|
for succ in bb.successors + bb.dummy_successors:
|
|
247
231
|
for x, use_bb in cfg.live_before[succ].items():
|
|
248
|
-
# Check that the variables requested by the successor are defined
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
232
|
+
# Check that the variables requested by the successor are defined. If `x` is
|
|
233
|
+
# a local variable, then we must be able to find it in the context.
|
|
234
|
+
# Following Python, locals are exactly those variables that are defined
|
|
235
|
+
# somewhere in the function body.
|
|
236
|
+
if x in cfg.assigned_somewhere:
|
|
237
|
+
if x not in ctx.locals:
|
|
238
|
+
# If the variable is defined on *some* paths, we can give a more
|
|
239
|
+
# informative error message
|
|
240
|
+
if x in cfg.maybe_ass_before[use_bb]:
|
|
241
|
+
err: Error = VarMaybeNotDefinedError(use_bb.vars.used[x], x)
|
|
242
|
+
if bad_branch := diagnose_maybe_undefined(use_bb, x, cfg):
|
|
243
|
+
branch_expr, truth_value = bad_branch
|
|
244
|
+
note = VarMaybeNotDefinedError.BadBranch(
|
|
245
|
+
branch_expr, x, truth_value
|
|
246
|
+
)
|
|
247
|
+
err.add_sub_diagnostic(note)
|
|
248
|
+
else:
|
|
249
|
+
err = VarNotDefinedError(use_bb.vars.used[x], x)
|
|
264
250
|
raise GuppyError(err)
|
|
251
|
+
# If x is not a local, then it must be a global or generic param
|
|
252
|
+
elif x not in ctx.globals and x not in ctx.generic_params:
|
|
265
253
|
raise GuppyError(VarNotDefinedError(use_bb.vars.used[x], x))
|
|
266
254
|
|
|
267
255
|
# Finally, we need to compute the signature of the basic block
|
|
@@ -287,9 +275,7 @@ def check_bb(
|
|
|
287
275
|
return checked_bb
|
|
288
276
|
|
|
289
277
|
|
|
290
|
-
def check_rows_match(
|
|
291
|
-
row1: Row[Variable], row2: Row[Variable], bb: BB, globals: Globals
|
|
292
|
-
) -> None:
|
|
278
|
+
def check_rows_match(row1: Row[Variable], row2: Row[Variable], bb: BB) -> None:
|
|
293
279
|
"""Checks that the types of two rows match up.
|
|
294
280
|
|
|
295
281
|
Otherwise, an error is thrown, alerting the user that a variable has different
|
|
@@ -299,10 +285,7 @@ def check_rows_match(
|
|
|
299
285
|
for x in map1.keys() | map2.keys():
|
|
300
286
|
# If block signature lengths don't match but no undefined error was thrown, some
|
|
301
287
|
# variables may be shadowing global variables.
|
|
302
|
-
v1 = map1
|
|
303
|
-
assert isinstance(v1, Variable | ValueDef)
|
|
304
|
-
v2 = map2.get(x) or cast(ValueDef, globals[x])
|
|
305
|
-
assert isinstance(v2, Variable | ValueDef)
|
|
288
|
+
v1, v2 = map1[x], map2[x]
|
|
306
289
|
if v1.ty != v2.ty:
|
|
307
290
|
# In the error message, we want to mention the variable that was first
|
|
308
291
|
# defined at the start.
|
|
@@ -320,31 +303,9 @@ def check_rows_match(
|
|
|
320
303
|
# We don't add a location to the type hint for the global variable,
|
|
321
304
|
# since it could lead to cross-file diagnostics (which are not
|
|
322
305
|
# supported) or refer to long function definitions.
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if isinstance(v1, Variable)
|
|
326
|
-
else BranchTypeError.GlobalHint(None, v1)
|
|
327
|
-
)
|
|
328
|
-
sub2 = (
|
|
329
|
-
BranchTypeError.TypeHint(v2.defined_at, v2.ty)
|
|
330
|
-
if isinstance(v2, Variable)
|
|
331
|
-
else BranchTypeError.GlobalHint(None, v2)
|
|
332
|
-
)
|
|
333
|
-
err.add_sub_diagnostic(sub1)
|
|
334
|
-
err.add_sub_diagnostic(sub2)
|
|
306
|
+
err.add_sub_diagnostic(BranchTypeError.TypeHint(v1.defined_at, v1.ty))
|
|
307
|
+
err.add_sub_diagnostic(BranchTypeError.TypeHint(v2.defined_at, v2.ty))
|
|
335
308
|
raise GuppyError(err)
|
|
336
|
-
else:
|
|
337
|
-
# TODO: Remove once https://github.com/CQCL/guppylang/issues/827 is done.
|
|
338
|
-
# If either is a global variable, don't allow shadowing even if types match.
|
|
339
|
-
if not (isinstance(v1, Variable) and isinstance(v2, Variable)):
|
|
340
|
-
local_var = v1 if isinstance(v1, Variable) else v2
|
|
341
|
-
ident = (
|
|
342
|
-
"Expression"
|
|
343
|
-
if local_var.name.startswith("%")
|
|
344
|
-
else f"Variable `{local_var.name}`"
|
|
345
|
-
)
|
|
346
|
-
glob_err = GlobalShadowError(local_var.defined_at, ident)
|
|
347
|
-
raise GuppyError(glob_err)
|
|
348
309
|
|
|
349
310
|
|
|
350
311
|
def diagnose_maybe_undefined(
|
|
@@ -1309,11 +1309,7 @@ def eval_comptime_expr(node: ComptimeExpr, ctx: Context) -> Any:
|
|
|
1309
1309
|
raise GuppyError(ComptimeExprNotCPythonError(node))
|
|
1310
1310
|
|
|
1311
1311
|
try:
|
|
1312
|
-
python_val = eval( # noqa: S307
|
|
1313
|
-
ast.unparse(node.value),
|
|
1314
|
-
None,
|
|
1315
|
-
DummyEvalDict(ctx, node.value),
|
|
1316
|
-
)
|
|
1312
|
+
python_val = eval(ast.unparse(node.value), DummyEvalDict(ctx, node.value)) # noqa: S307
|
|
1317
1313
|
except DummyEvalDict.GuppyVarUsedError as e:
|
|
1318
1314
|
raise GuppyError(ComptimeExprNotStaticError(e.node or node, e.var)) from None
|
|
1319
1315
|
except Exception as e:
|
|
File without changes
|
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/ast_util.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/cfg/__init__.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/cfg/analysis.py
RENAMED
|
File without changes
|
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/cfg/builder.py
RENAMED
|
File without changes
|
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/checker/core.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/compiler/core.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/decorator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/ty.py
RENAMED
|
File without changes
|
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/definition/wasm.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/diagnostic.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/dummy_decorator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/experimental.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/ipython_inspect.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/std/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tracing/object.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tracing/state.py
RENAMED
|
File without changes
|
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tracing/util.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/__init__.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/arg.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/builtin.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/common.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/const.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/errors.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/param.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/parsing.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/printing.py
RENAMED
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/subst.py
RENAMED
|
File without changes
|
|
File without changes
|
{guppylang_internals-0.22.0 → guppylang_internals-0.23.0}/src/guppylang_internals/tys/var.py
RENAMED
|
File without changes
|