Compare commits
21
Commits
9f3c8b96e9
...
official
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12c5309cff | ||
|
|
720a82c221
|
||
|
|
90e9d167bf
|
||
|
|
4866ab2090
|
||
|
|
3ede752cae
|
||
|
|
244e5f351a
|
||
|
|
e61c4070da
|
||
|
|
00fdda5034
|
||
|
|
e302ed2377 | ||
|
|
1d927e532f
|
||
|
|
bfe4f854ea
|
||
|
|
3e06a236b5 | ||
|
|
ab53ac67d5
|
||
|
|
b3ff5a7b96 | ||
|
|
dce35391b4
|
||
|
|
28be45eb8f
|
||
|
|
b64110bb06
|
||
|
|
edc2a65492
|
||
|
|
dade8eb0f4
|
||
|
|
9f3dfd686b
|
||
|
|
5ef21917ae
|
@@ -0,0 +1,202 @@
|
|||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright 2026 Louis Heredero
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
@@ -1,5 +1,11 @@
|
|||||||
<h1>Midas</h1>
|
<h1>Midas</h1>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="assets/icon.svg" width="64">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<img src="https://git.kb28.ch/HEL/midas/actions/workflows/tests.yaml/badge.svg">
|
||||||
|
|
||||||
*Midas* is a type system to _Maintain Integrity of Data with Annotated Structures_. In Greek mythology, [Midas](https://en.wikipedia.org/wiki/Midas) was a Phrygian king who was blessed with the gift of turning everything he touched into gold.
|
*Midas* is a type system to _Maintain Integrity of Data with Annotated Structures_. In Greek mythology, [Midas](https://en.wikipedia.org/wiki/Midas) was a Phrygian king who was blessed with the gift of turning everything he touched into gold.
|
||||||
|
|
||||||
*Midas* aims at providing Python developers with a simple annotation system to enable compile-time integrity and data type checks, as well as generating runtime assertions.
|
*Midas* aims at providing Python developers with a simple annotation system to enable compile-time integrity and data type checks, as well as generating runtime assertions.
|
||||||
@@ -22,6 +28,8 @@ This framework is being developed as part of a Bachelor's Thesis by Louis Herede
|
|||||||
- [Showing Type Judgements](#showing-type-judgements)
|
- [Showing Type Judgements](#showing-type-judgements)
|
||||||
- [Validating Definitions](#validating-definitions)
|
- [Validating Definitions](#validating-definitions)
|
||||||
- [Tests](#tests)
|
- [Tests](#tests)
|
||||||
|
- [Contributing](#contributing)
|
||||||
|
- [License](#license)
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
|
||||||
@@ -161,3 +169,16 @@ Not specifying any subcommand is equivalent to running `run -a`
|
|||||||
- Run specific tests: `run tests/cases/test1.py tests/cases/test2.py ...`
|
- Run specific tests: `run tests/cases/test1.py tests/cases/test2.py ...`
|
||||||
- Update all tests: `update -a`
|
- Update all tests: `update -a`
|
||||||
- Update specific tests: `update tests/cases/test1.py tests/cases/test2.py ...`
|
- Update specific tests: `update tests/cases/test1.py tests/cases/test2.py ...`
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Feel free to [open an issue](https://git.kb28.ch/HEL/midas/issues) to report a bug or if you experience any issues with Midas.
|
||||||
|
|
||||||
|
Contributions are also welcome so feel free to [open a pull request](https://git.kb28.ch/HEL/midas/pulls).
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> As this is part of my bachelor project, I will not accept any contributions before my defense
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Midas is distributed under the terms of the Apache-2.0 license. See [LICENSE](LICENSE) for details.
|
||||||
@@ -1,150 +0,0 @@
|
|||||||
#import "@preview/cetz:0.5.2": canvas, draw
|
|
||||||
|
|
||||||
#let diagram-only = false
|
|
||||||
|
|
||||||
#set document(
|
|
||||||
title: [Midas Architecture],
|
|
||||||
//author: "Louis Heredero",
|
|
||||||
)
|
|
||||||
|
|
||||||
#set text(
|
|
||||||
font: "Source Sans 3",
|
|
||||||
)
|
|
||||||
|
|
||||||
#let diagram = canvas({
|
|
||||||
let framed = draw.content.with(
|
|
||||||
padding: (x: .8em, y: 1em),
|
|
||||||
frame: "rect",
|
|
||||||
stroke: black,
|
|
||||||
)
|
|
||||||
let arrow = draw.line.with(mark: (end: ">", fill: black))
|
|
||||||
framed(
|
|
||||||
(0, 0),
|
|
||||||
name: "python-parser",
|
|
||||||
)[Python parser]
|
|
||||||
|
|
||||||
draw.content(
|
|
||||||
(rel: (0, 1), to: "python-parser.north"),
|
|
||||||
padding: 5pt,
|
|
||||||
anchor: "south",
|
|
||||||
name: "source-py",
|
|
||||||
)[_`source.py`_]
|
|
||||||
arrow("source-py", "python-parser")
|
|
||||||
|
|
||||||
framed(
|
|
||||||
(rel: (3, 0), to: "python-parser.east"),
|
|
||||||
anchor: "west",
|
|
||||||
name: "custom-parser",
|
|
||||||
align(center)[Custom python\ parser],
|
|
||||||
)
|
|
||||||
|
|
||||||
arrow("python-parser", "custom-parser", name: "arrow-python-ast")
|
|
||||||
draw.content(
|
|
||||||
"arrow-python-ast",
|
|
||||||
anchor: "south",
|
|
||||||
padding: 5pt,
|
|
||||||
)[`ast.Module`]
|
|
||||||
|
|
||||||
framed(
|
|
||||||
(rel: (-3, -2), to: "custom-parser.south"),
|
|
||||||
anchor: "east",
|
|
||||||
name: "python-resolver",
|
|
||||||
)[Python Resolver]
|
|
||||||
arrow(
|
|
||||||
"custom-parser",
|
|
||||||
((), "|-", "python-resolver.east"),
|
|
||||||
"python-resolver",
|
|
||||||
name: "arrow-python-custom-ast",
|
|
||||||
)
|
|
||||||
draw.content(
|
|
||||||
(rel: (1.5, 0), to: "arrow-python-custom-ast.end"),
|
|
||||||
padding: 5pt,
|
|
||||||
anchor: "south",
|
|
||||||
)[P-AST#footnote[#strong[P]ython *AST*]<fn-past>]
|
|
||||||
draw.content(
|
|
||||||
"python-resolver.west",
|
|
||||||
padding: 5pt,
|
|
||||||
anchor: "south-east",
|
|
||||||
)[Resolved P-AST@fn-past]
|
|
||||||
|
|
||||||
draw.circle(
|
|
||||||
(rel: (1, -2), to: "custom-parser.south-east"),
|
|
||||||
radius: .4,
|
|
||||||
name: "midas-loader",
|
|
||||||
)
|
|
||||||
arrow(
|
|
||||||
"custom-parser",
|
|
||||||
"midas-loader",
|
|
||||||
name: "arrow-load-midas",
|
|
||||||
mark: (end: (symbol: ">", fill: black), start: "o"),
|
|
||||||
)
|
|
||||||
draw.content(
|
|
||||||
"arrow-load-midas",
|
|
||||||
anchor: "west",
|
|
||||||
padding: 5pt,
|
|
||||||
)[```python midas.using("types.midas")```]
|
|
||||||
|
|
||||||
framed(
|
|
||||||
(rel: (0, -2), to: "midas-loader.south"),
|
|
||||||
name: "midas-parser",
|
|
||||||
)[Midas lexer/parser]
|
|
||||||
arrow("midas-loader", "midas-parser", name: "arrow-midas-source")
|
|
||||||
draw.content(
|
|
||||||
"arrow-midas-source",
|
|
||||||
anchor: "west",
|
|
||||||
padding: 5pt,
|
|
||||||
)[_`types.midas`_]
|
|
||||||
|
|
||||||
|
|
||||||
framed(
|
|
||||||
(rel: (-2, 0), to: "midas-parser.west"),
|
|
||||||
anchor: "east",
|
|
||||||
name: "midas-resolver",
|
|
||||||
)[Midas Resolver]
|
|
||||||
arrow("midas-parser", "midas-resolver", name: "arrow-midas-ast")
|
|
||||||
draw.content(
|
|
||||||
"arrow-midas-ast",
|
|
||||||
anchor: "south",
|
|
||||||
padding: 5pt,
|
|
||||||
)[M-AST#footnote[#strong[M]idas *AST*]<fn-mast>]
|
|
||||||
|
|
||||||
framed(
|
|
||||||
(rel: (-3, 0), to: "midas-resolver.west"),
|
|
||||||
anchor: "east",
|
|
||||||
name: "checker",
|
|
||||||
)[Checker]
|
|
||||||
arrow("midas-resolver", "checker", name: "arrow-type-ctx")
|
|
||||||
arrow(
|
|
||||||
"python-resolver",
|
|
||||||
((), "-|", "checker.north"),
|
|
||||||
"checker",
|
|
||||||
)
|
|
||||||
draw.content(
|
|
||||||
"arrow-type-ctx",
|
|
||||||
anchor: "south",
|
|
||||||
padding: 5pt,
|
|
||||||
)[Types context]
|
|
||||||
})
|
|
||||||
|
|
||||||
#show: doc => if diagram-only {
|
|
||||||
set page(width: auto, height: auto, margin: .5cm)
|
|
||||||
diagram
|
|
||||||
} else { doc }
|
|
||||||
|
|
||||||
#align(center, title())
|
|
||||||
|
|
||||||
#v(1cm)
|
|
||||||
|
|
||||||
#figure(
|
|
||||||
diagram,
|
|
||||||
caption: [Midas type-checker architecture],
|
|
||||||
)
|
|
||||||
|
|
||||||
== Components
|
|
||||||
|
|
||||||
- *Python parser*: builtin Python AST parser, extracts abstract syntax from the raw Python source (```python ast.parse(...)```)
|
|
||||||
- *Custom python parser*: converts the raw Python AST into custom, more suitable constructs, especially for type annotations
|
|
||||||
- *Python resolver*: resolves bindings and references, tracks binding scopes
|
|
||||||
- *Midas lexer/parser*: parses a Midas type definition file and extracts its AST
|
|
||||||
- *Midas resolver*: walks the AST and fills the environment with the defined types and operations
|
|
||||||
- *Checker*: evaluates expressions and checks type coherence
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
# type: ignore
|
|
||||||
# ruff: disable[F821]
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
# A simple data-frame with different column of various simple types
|
|
||||||
# Columns can be named and/or typed
|
|
||||||
df: Frame[
|
|
||||||
verified: bool,
|
|
||||||
birth_year: int,
|
|
||||||
height: float + ( _ > 0 ) + ( _ < 250 ),
|
|
||||||
name: str,
|
|
||||||
date: datetime,
|
|
||||||
float, # unnamed
|
|
||||||
unknown: _, # untyped
|
|
||||||
_ # unnamed and untyped
|
|
||||||
]
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
// Simple custom type derived from floats
|
|
||||||
type Latitude<float>
|
|
||||||
type Longitude<float>
|
|
||||||
|
|
||||||
// Complex custom type, containing two values accessible through properties
|
|
||||||
type GeoLocation<Latitude, Longitude> {
|
|
||||||
lat: Latitude
|
|
||||||
lon: Longitude
|
|
||||||
}
|
|
||||||
|
|
||||||
type LatitudeDiff<float>
|
|
||||||
type LongitudeDiff<float>
|
|
||||||
|
|
||||||
// Simple operation defined on our custom types
|
|
||||||
op <Latitude> - <Latitude> = <LatitudeDiff>
|
|
||||||
op <Longitude> - <Longitude> = <LongitudeDiff>
|
|
||||||
|
|
||||||
// Simple custom type with a constraint
|
|
||||||
type Age<int + (0 <= _) + (_ < 150)>
|
|
||||||
|
|
||||||
// Predefined custom constraints that can be referenced in other definitions
|
|
||||||
constraint Positive = _ >= 0
|
|
||||||
constraint StrictlyPositive = _ > 0
|
|
||||||
//constraint Even = _ % 2 == 0
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
# type: ignore
|
|
||||||
# ruff: disable[F821]
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
# A data-frame using a custom type
|
|
||||||
df: Frame[
|
|
||||||
location: GeoLocation
|
|
||||||
]
|
|
||||||
|
|
||||||
# Properties of a type can be used on a column of that type
|
|
||||||
lat: Column[GeoLocation] = df["location"].lat
|
|
||||||
lon: Column[GeoLocation] = df["location"].lon
|
|
||||||
|
|
||||||
# Unregistered operations between types are not permitted
|
|
||||||
lat + lon # Invalid operation
|
|
||||||
|
|
||||||
# Registered operations are permitted
|
|
||||||
lat1: Latitude = lat[0]
|
|
||||||
lat2: Latitude = lat[1]
|
|
||||||
lat_diff: Difference[Latitude] = lat2 - lat1 # Valid operation
|
|
||||||
|
|
||||||
# In addition to the type, a column can have one or more constraints, either defined inline or in a separate file
|
|
||||||
df2: Frame[
|
|
||||||
age: int + (_ >= 0),
|
|
||||||
height: float + (_ >= 0),
|
|
||||||
]
|
|
||||||
df2_bis: Frame[
|
|
||||||
age: int + Positive,
|
|
||||||
height: float + Positive,
|
|
||||||
]
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
// Simple custom type derived from float
|
|
||||||
type Custom(float)
|
|
||||||
|
|
||||||
// Simple custom types with constraints
|
|
||||||
type Latitude(float) where (-90 <= _ <= 90)
|
|
||||||
type Longitude(float) where (-180 <= _ <= 180)
|
|
||||||
|
|
||||||
// Generic custom type (a Difference of T is derived from T, e.g. a difference of floats is a float
|
|
||||||
type Difference[T](T)
|
|
||||||
|
|
||||||
// Complex custom type, containing two values accessible through properties
|
|
||||||
type GeoLocation {
|
|
||||||
lat: Latitude
|
|
||||||
lon: Longitude
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define operations on our custom type
|
|
||||||
extend GeoLocation {
|
|
||||||
// This type is compatible with the `-` operation with another GeoLocation
|
|
||||||
// i.e. you can subtract a GeoLocation from another GeoLocation, resulting
|
|
||||||
// in a Difference of GeoLocations
|
|
||||||
op __sub__(GeoLocation) -> Difference[GeoLocation]
|
|
||||||
}
|
|
||||||
|
|
||||||
// For complex generics, you need to specify how the genericity the properties
|
|
||||||
// are handled
|
|
||||||
type Difference[GeoLocation] {
|
|
||||||
lat: Difference[Latitude]
|
|
||||||
lon: Difference[Longitude]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Simple operation defined on our custom types
|
|
||||||
extend Latitude {
|
|
||||||
op __sub__(Latitude) -> Difference[Latitude]
|
|
||||||
}
|
|
||||||
|
|
||||||
extend Longitude {
|
|
||||||
op __sub__(Longitude) -> Difference[Longitude]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Predefined custom predicates that can be referenced in other definitions
|
|
||||||
predicate Positive(v: float) = v >= 0
|
|
||||||
predicate StrictlyPositive(v: float) = v > 0
|
|
||||||
predicate Equatorial(loc: GeoLocation) = (-10 <= loc.lat <= 10)
|
|
||||||
predicate Arctic(loc: GeoLocation) = (loc.lat >= 66)
|
|
||||||
|
|
||||||
type Person {
|
|
||||||
name: str
|
|
||||||
|
|
||||||
// Property with an inline constraint
|
|
||||||
age: int? where (0 <= _ < 150)
|
|
||||||
|
|
||||||
// Property referencing a predicate
|
|
||||||
height: float where StrictlyPositive
|
|
||||||
|
|
||||||
home: GeoLocation
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom complex type derived from another complex type, with a constraint
|
|
||||||
// on a property
|
|
||||||
// Multiple proposed syntaxes, not yet defined
|
|
||||||
|
|
||||||
// Explicit, but new keyword
|
|
||||||
type EquatorialPerson refines Person where Equatorial(_.home)
|
|
||||||
|
|
||||||
// Explicit with existing keyword, might be confusing if expectations regarding 'is'
|
|
||||||
type EquatorialPerson is Person where Equatorial(_.home)
|
|
||||||
|
|
||||||
// Consistent and Python-friendly but can be confused with structural extension
|
|
||||||
type EquatorialPerson(Person) where Equatorial(_.home)
|
|
||||||
|
|
||||||
// Allow new properties, probably not useful
|
|
||||||
type EquatorialPerson extends Person where Equatorial(_.home)
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# type: ignore
|
|
||||||
# ruff: disable[F821]
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
|
|
||||||
def func(
|
|
||||||
col1: Column[float + (0 <= _ <= 1)],
|
|
||||||
col2: Column[float + (0 <= _ <= 1)],
|
|
||||||
) -> Column[float + (0 <= _ <= 2)]:
|
|
||||||
result: Column[float + (0 <= _ <= 2)] = col1 + col2
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def func2(a: int, /, b: float, *, c: str):
|
|
||||||
pass
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
type Foo1 = float
|
|
||||||
type Foo2 = float where (_ > 3)
|
|
||||||
type Foo3 = int | float
|
|
||||||
type Foo4 = int where (_ > 3) | float where (_ > 3)
|
|
||||||
type Foo5 = (int | float) where (_ > 3)
|
|
||||||
type Foo6 = {
|
|
||||||
foo: float
|
|
||||||
bar: float where (_ > 3)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Foo7[T] = T where (_ > 3)
|
|
||||||
type Foo8[A, B<:int] = {
|
|
||||||
a: A
|
|
||||||
b: B
|
|
||||||
}
|
|
||||||
|
|
||||||
type Complex = {
|
|
||||||
a: int
|
|
||||||
b: int
|
|
||||||
}
|
|
||||||
type Complex2 = Complex where (_.a > 3 & _.b < 5)
|
|
||||||
|
|
||||||
predicate Positive(n: int) = n >= 0
|
|
||||||
|
|
||||||
extend Foo1 {
|
|
||||||
op __add__(Foo1) -> Foo1
|
|
||||||
}
|
|
||||||
|
|
||||||
extend Foo7[T] {
|
|
||||||
op __add__(Foo7[T]) -> Foo7[T]
|
|
||||||
}
|
|
||||||
|
|
||||||
type Optional[T] = None | T
|
|
||||||
@@ -6,7 +6,7 @@ c = a + b # -> int
|
|||||||
c = "invalid" # -> can't assign str to int variable
|
c = "invalid" # -> can't assign str to int variable
|
||||||
|
|
||||||
d = True
|
d = True
|
||||||
e = d + d
|
e = d + d # -> addition not defined between booleans
|
||||||
|
|
||||||
f: float = a
|
f: float = a
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# type: ignore
|
# type: ignore
|
||||||
# ruff: disable [F821]
|
# ruff: disable [F821]
|
||||||
|
|
||||||
distance: Meter = cast(Meter, 123.45)
|
distance = cast(Meter, 123.45)
|
||||||
time: Second = cast(Second, 6.7)
|
time = cast(Second, 6.7)
|
||||||
speed = distance / time
|
speed = distance / time
|
||||||
|
print(speed)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
# Return types must have a LUB
|
||||||
|
# Valid
|
||||||
def minimum(x: int, y: int):
|
def minimum(x: int, y: int):
|
||||||
if x < y:
|
if x < y:
|
||||||
return x
|
return x
|
||||||
@@ -5,18 +7,28 @@ def minimum(x: int, y: int):
|
|||||||
return y
|
return y
|
||||||
|
|
||||||
|
|
||||||
|
# Invalid
|
||||||
|
def func(a: int):
|
||||||
|
if a < 5:
|
||||||
|
return "Oops"
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
a = 15
|
a = 15
|
||||||
b = 72
|
b = 72
|
||||||
c = minimum(a, b)
|
c = minimum(a, b)
|
||||||
|
|
||||||
|
|
||||||
|
# Recursive but typable thanks to return hint
|
||||||
def factorial(n: int) -> int:
|
def factorial(n: int) -> int:
|
||||||
if n <= 1:
|
if n <= 1:
|
||||||
return 1
|
return 1
|
||||||
return n * factorial(n - 1)
|
return n * factorial(n - 1)
|
||||||
|
|
||||||
|
|
||||||
category = "Category 1" if a < 10 else "Category 2"
|
# Branches must be of the same type
|
||||||
|
category = "Category 1" if a < 10 else "Category 2" # Valid
|
||||||
|
category = "Category 1" if a < 10 else 3 # Invalid
|
||||||
|
|
||||||
|
|
||||||
def foo() -> None:
|
def foo() -> None:
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ extend Coordinate {
|
|||||||
type Difference[T <: float] = T
|
type Difference[T <: float] = T
|
||||||
type MeterDifference = Difference[Meter]
|
type MeterDifference = Difference[Meter]
|
||||||
|
|
||||||
type CompDiff[T <: float] = {
|
type CompDiff[T <: float] = object
|
||||||
|
|
||||||
|
extend CompDiff[T <: float] {
|
||||||
prop d1: Difference[T]
|
prop d1: Difference[T]
|
||||||
prop d2: Difference[T]
|
prop d2: Difference[T]
|
||||||
}
|
}
|
||||||
@@ -1,20 +1,20 @@
|
|||||||
# type: ignore
|
# type: ignore
|
||||||
# ruff: disable [F821]
|
# ruff: disable [F821]
|
||||||
|
|
||||||
p1: Coordinate
|
p1 = cast(Coordinate, object())
|
||||||
p2: Coordinate
|
p2 = cast(Coordinate, object())
|
||||||
|
|
||||||
diff_x = p2.x - p1.x
|
diff_x = p2.x - p1.x
|
||||||
diff_y = p2.y - p1.y
|
diff_y = p2.y - p1.y
|
||||||
|
|
||||||
dist = diff_x + diff_y
|
dist = diff_x + diff_y
|
||||||
|
|
||||||
p2.x += cast(Meter, 1)
|
p2.x += cast(Meter, 1.0)
|
||||||
p2.y = True # invalid, wrong type
|
p2.y = True # invalid, wrong type
|
||||||
p2.z = 3 # invalid, no property 'z' on Coordinate
|
p2.z = 3 # invalid, no property 'z' on Coordinate
|
||||||
p2.x.a = 3 # invalid, no properties on Meter
|
p2.x.a = 3 # invalid, no properties on Meter
|
||||||
|
|
||||||
foo: list[float] = []
|
foo = cast(list[float], [])
|
||||||
|
|
||||||
append = foo.append
|
append = foo.append
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ foo.append(2)
|
|||||||
append(True) # invalid, must be float
|
append(True) # invalid, must be float
|
||||||
append(2)
|
append(2)
|
||||||
|
|
||||||
bar: list[list[Meter]]
|
bar = cast(list[list[Meter]], [])
|
||||||
|
|
||||||
bar.append([p2.x])
|
bar.append([p2.x])
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# type: ignore
|
# type: ignore
|
||||||
# ruff: disable [F821]
|
# ruff: disable [F821]
|
||||||
|
|
||||||
foo: Foo
|
foo = cast(Foo, object())
|
||||||
t1: T1
|
t1 = cast(T1, object())
|
||||||
t2: T2
|
t2 = cast(T2, object())
|
||||||
|
|
||||||
a = foo.bar(t1)
|
a = foo.bar(t1)
|
||||||
b = foo.bar(t2)
|
b = foo.bar(t2)
|
||||||
@@ -13,6 +13,6 @@ func = foo.bar
|
|||||||
c = func(t1)
|
c = func(t1)
|
||||||
d = func(t2)
|
d = func(t2)
|
||||||
|
|
||||||
t2b: T2b
|
t2b = cast(T2b, object())
|
||||||
|
|
||||||
e = foo.bar(t2b)
|
e = foo.bar(t2b)
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
from __future__ import annotations
|
|
||||||
from typing import Generic, TypeVar
|
|
||||||
|
|
||||||
class Currency(float): ...
|
|
||||||
|
|
||||||
_T0 = TypeVar("_T0", bound=Currency, covariant=True)
|
|
||||||
|
|
||||||
class Price(Currency, Generic[_T0]):
|
|
||||||
def __add__(self, _0: Price[_T0], /) -> Price[_T0]: ...
|
|
||||||
|
|
||||||
class EUR(Currency): ...
|
|
||||||
class USD(Currency): ...
|
|
||||||
class CHF(Currency): ...
|
|
||||||
class Discount(float): ...
|
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Local Variables:
|
||||||
|
# mode: makefile
|
||||||
|
# End:
|
||||||
|
set shell := ["bash", "-uc"]
|
||||||
|
|
||||||
|
build-docs:
|
||||||
|
typst c --root . docs/manual.typ
|
||||||
|
typst c --root . docs/function_subtyping.typ
|
||||||
|
|
||||||
|
tests:
|
||||||
|
uv run -m tests
|
||||||
|
|
||||||
|
check-docstrings:
|
||||||
|
uv run scripts/docstring_checker.py
|
||||||
@@ -86,6 +86,9 @@ class ColumnGroupByMethodRegistry(MethodRegistry[Call]):
|
|||||||
|
|
||||||
# TODO: maybe better to filter arguments and pass some, in case the
|
# TODO: maybe better to filter arguments and pass some, in case the
|
||||||
# return type depends on them
|
# return type depends on them
|
||||||
|
|
||||||
|
# Don't catch UndefinedMethodException because all aggregation
|
||||||
|
# methods should be defined on columns too
|
||||||
returns: Type = self.typer.call_method(
|
returns: Type = self.typer.call_method(
|
||||||
location=call.location,
|
location=call.location,
|
||||||
call_expr=call.call_expr,
|
call_expr=call.call_expr,
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ class FrameGroupByMethodRegistry(MethodRegistry[Call]):
|
|||||||
for column in call.groupby.frame.columns:
|
for column in call.groupby.frame.columns:
|
||||||
with self.reporter.with_context(f"in column '{column.name}'"):
|
with self.reporter.with_context(f"in column '{column.name}'"):
|
||||||
column_groupby: ColumnGroupBy = ColumnGroupBy(column=column.type)
|
column_groupby: ColumnGroupBy = ColumnGroupBy(column=column.type)
|
||||||
|
# Don't catch UndefinedMethodException because all aggregation
|
||||||
|
# methods should be defined on columns too
|
||||||
result_type: Type = self.typer.call_method(
|
result_type: Type = self.typer.call_method(
|
||||||
location=call.location,
|
location=call.location,
|
||||||
call_expr=call.call_expr,
|
call_expr=call.call_expr,
|
||||||
|
|||||||
+11
-1
@@ -170,7 +170,10 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[Type], m.Type.Visitor[Type
|
|||||||
type = GenericType(name=name, params=params, body=type)
|
type = GenericType(name=name, params=params, body=type)
|
||||||
else:
|
else:
|
||||||
type = DerivedType(name=name, type=type)
|
type = DerivedType(name=name, type=type)
|
||||||
|
try:
|
||||||
self.types.define_type(name, type)
|
self.types.define_type(name, type)
|
||||||
|
except ValueError:
|
||||||
|
self.reporter.error(stmt.location, f"Type {name} already defined")
|
||||||
self._local_variables.clear()
|
self._local_variables.clear()
|
||||||
self._current_name = None
|
self._current_name = None
|
||||||
|
|
||||||
@@ -178,7 +181,10 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[Type], m.Type.Visitor[Type
|
|||||||
name: str = stmt.name.lexeme
|
name: str = stmt.name.lexeme
|
||||||
self._current_name = name
|
self._current_name = name
|
||||||
type: Type = stmt.type.accept(self)
|
type: Type = stmt.type.accept(self)
|
||||||
|
try:
|
||||||
self.types.define_type(name, type)
|
self.types.define_type(name, type)
|
||||||
|
except ValueError:
|
||||||
|
self.reporter.error(stmt.location, f"Type {name} already defined")
|
||||||
self._current_name = None
|
self._current_name = None
|
||||||
|
|
||||||
def visit_member_stmt(self, stmt: m.MemberStmt) -> None: ...
|
def visit_member_stmt(self, stmt: m.MemberStmt) -> None: ...
|
||||||
@@ -201,6 +207,7 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[Type], m.Type.Visitor[Type
|
|||||||
)
|
)
|
||||||
|
|
||||||
def visit_predicate_stmt(self, stmt: m.PredicateStmt) -> None:
|
def visit_predicate_stmt(self, stmt: m.PredicateStmt) -> None:
|
||||||
|
name: str = stmt.name.lexeme
|
||||||
for spec in stmt.params:
|
for spec in stmt.params:
|
||||||
for param in spec.mixed:
|
for param in spec.mixed:
|
||||||
assert param.name is not None
|
assert param.name is not None
|
||||||
@@ -222,14 +229,17 @@ class MidasTyper(m.Stmt.Visitor[None], m.Expr.Visitor[Type], m.Type.Visitor[Type
|
|||||||
returns=type,
|
returns=type,
|
||||||
)
|
)
|
||||||
self._predicate_params = {}
|
self._predicate_params = {}
|
||||||
|
try:
|
||||||
self.types.define_predicate(
|
self.types.define_predicate(
|
||||||
stmt.name.lexeme,
|
name,
|
||||||
Predicate(
|
Predicate(
|
||||||
type=type,
|
type=type,
|
||||||
body=stmt.body,
|
body=stmt.body,
|
||||||
alias=len(params) == 0,
|
alias=len(params) == 0,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
except ValueError:
|
||||||
|
self.reporter.error(stmt.location, f"Predicate {name} already defined")
|
||||||
|
|
||||||
def _is_valid_predicate(self, body: Type) -> bool:
|
def _is_valid_predicate(self, body: Type) -> bool:
|
||||||
"""Check whether the given type is valid as a predicate's body
|
"""Check whether the given type is valid as a predicate's body
|
||||||
|
|||||||
+37
-4
@@ -48,7 +48,9 @@ TypedExpr = tuple[p.Expr, Type]
|
|||||||
|
|
||||||
|
|
||||||
class ReturnException(Exception):
|
class ReturnException(Exception):
|
||||||
pass
|
def __init__(self, stmt: p.Stmt):
|
||||||
|
super().__init__()
|
||||||
|
self.stmt: p.Stmt = stmt
|
||||||
|
|
||||||
|
|
||||||
class UndefinedMethodException(Exception):
|
class UndefinedMethodException(Exception):
|
||||||
@@ -116,7 +118,10 @@ class PythonTyper(
|
|||||||
self.judgements = []
|
self.judgements = []
|
||||||
self.evaluated_casts = []
|
self.evaluated_casts = []
|
||||||
|
|
||||||
|
try:
|
||||||
self.check(stmts)
|
self.check(stmts)
|
||||||
|
except ReturnException as e:
|
||||||
|
self.reporter.error(e.stmt.location, "Return statement outside of function")
|
||||||
|
|
||||||
return TypedAST(
|
return TypedAST(
|
||||||
stmts=stmts,
|
stmts=stmts,
|
||||||
@@ -576,7 +581,7 @@ class PythonTyper(
|
|||||||
def visit_return_stmt(self, stmt: p.ReturnStmt) -> None:
|
def visit_return_stmt(self, stmt: p.ReturnStmt) -> None:
|
||||||
type: Type = self.type_of(stmt.value) if stmt.value is not None else UnitType()
|
type: Type = self.type_of(stmt.value) if stmt.value is not None else UnitType()
|
||||||
self.env.return_types.append(type)
|
self.env.return_types.append(type)
|
||||||
raise ReturnException()
|
raise ReturnException(stmt)
|
||||||
|
|
||||||
def visit_if_stmt(self, stmt: p.IfStmt) -> None:
|
def visit_if_stmt(self, stmt: p.IfStmt) -> None:
|
||||||
# Not evaluated in sub-environment because assignments in the test leak out of the if
|
# Not evaluated in sub-environment because assignments in the test leak out of the if
|
||||||
@@ -599,7 +604,7 @@ class PythonTyper(
|
|||||||
else_returned: bool = self.process_block(stmt.orelse, env)
|
else_returned: bool = self.process_block(stmt.orelse, env)
|
||||||
self.env.return_types.extend(env.return_types)
|
self.env.return_types.extend(env.return_types)
|
||||||
if body_returned and else_returned:
|
if body_returned and else_returned:
|
||||||
raise ReturnException()
|
raise ReturnException(stmt)
|
||||||
|
|
||||||
def visit_pass(self, stmt: p.Pass) -> None:
|
def visit_pass(self, stmt: p.Pass) -> None:
|
||||||
pass
|
pass
|
||||||
@@ -627,7 +632,7 @@ class PythonTyper(
|
|||||||
self.env = outer_env
|
self.env = outer_env
|
||||||
|
|
||||||
if body_returned:
|
if body_returned:
|
||||||
raise ReturnException()
|
raise ReturnException(stmt)
|
||||||
|
|
||||||
def visit_import_stmt(self, stmt: p.ImportStmt) -> None:
|
def visit_import_stmt(self, stmt: p.ImportStmt) -> None:
|
||||||
self._visit_imports(stmt.location, stmt.imports)
|
self._visit_imports(stmt.location, stmt.imports)
|
||||||
@@ -772,6 +777,7 @@ class PythonTyper(
|
|||||||
match expr.callee:
|
match expr.callee:
|
||||||
case p.GetExpr(object=obj, name=method):
|
case p.GetExpr(object=obj, name=method):
|
||||||
obj_type: Type = self.type_of(obj)
|
obj_type: Type = self.type_of(obj)
|
||||||
|
try:
|
||||||
return self.call_method(
|
return self.call_method(
|
||||||
location=expr.location,
|
location=expr.location,
|
||||||
call_expr=expr,
|
call_expr=expr,
|
||||||
@@ -780,6 +786,12 @@ class PythonTyper(
|
|||||||
positional=positional,
|
positional=positional,
|
||||||
keywords=keywords,
|
keywords=keywords,
|
||||||
)
|
)
|
||||||
|
except UndefinedMethodException:
|
||||||
|
self.reporter.error(
|
||||||
|
expr.location,
|
||||||
|
f"Unknown method {method} on type {obj_type}",
|
||||||
|
)
|
||||||
|
return UnknownType()
|
||||||
|
|
||||||
callee: Type = self.type_of(expr.callee)
|
callee: Type = self.type_of(expr.callee)
|
||||||
result: CallResult = self.dispatcher.get_result(
|
result: CallResult = self.dispatcher.get_result(
|
||||||
@@ -1001,7 +1013,11 @@ class PythonTyper(
|
|||||||
|
|
||||||
if len(node.args) != 0:
|
if len(node.args) != 0:
|
||||||
args: list[Type] = [self.resolve_type_expr(arg) for arg in node.args]
|
args: list[Type] = [self.resolve_type_expr(arg) for arg in node.args]
|
||||||
|
try:
|
||||||
return self.types.apply_generic(base, args)
|
return self.types.apply_generic(base, args)
|
||||||
|
except Exception as e:
|
||||||
|
self.reporter.error(node.location, f"Cannot apply generic type: {e}")
|
||||||
|
return UnknownType()
|
||||||
return base
|
return base
|
||||||
|
|
||||||
def visit_frame_column(self, node: p.FrameColumn) -> ColumnType:
|
def visit_frame_column(self, node: p.FrameColumn) -> ColumnType:
|
||||||
@@ -1078,10 +1094,13 @@ class PythonTyper(
|
|||||||
bound: Optional[Type] = None
|
bound: Optional[Type] = None
|
||||||
variance: Variance = Variance.INVARIANT
|
variance: Variance = Variance.INVARIANT
|
||||||
if "bound" in call.keywords:
|
if "bound" in call.keywords:
|
||||||
|
try:
|
||||||
bound_type: p.MidasType = self._parse_type_from_expr(
|
bound_type: p.MidasType = self._parse_type_from_expr(
|
||||||
call.keywords["bound"]
|
call.keywords["bound"]
|
||||||
)
|
)
|
||||||
bound = self.resolve_type_expr(bound_type)
|
bound = self.resolve_type_expr(bound_type)
|
||||||
|
except NotImplementedError:
|
||||||
|
bound = UnknownType()
|
||||||
|
|
||||||
if is_kw_true("covariant"):
|
if is_kw_true("covariant"):
|
||||||
variance = Variance.COVARIANT
|
variance = Variance.COVARIANT
|
||||||
@@ -1096,7 +1115,13 @@ class PythonTyper(
|
|||||||
else:
|
else:
|
||||||
variance = Variance.CONTRAVARIANT
|
variance = Variance.CONTRAVARIANT
|
||||||
var: TypeVar = TypeVar(name=name, bound=bound, variance=variance)
|
var: TypeVar = TypeVar(name=name, bound=bound, variance=variance)
|
||||||
|
try:
|
||||||
self.types.define_type(name, var)
|
self.types.define_type(name, var)
|
||||||
|
except ValueError:
|
||||||
|
self.reporter.error(
|
||||||
|
call.location,
|
||||||
|
f"A type or type variable with the name {name} is already defined",
|
||||||
|
)
|
||||||
return var
|
return var
|
||||||
|
|
||||||
case _:
|
case _:
|
||||||
@@ -1127,6 +1152,14 @@ class PythonTyper(
|
|||||||
return parser._parse_type(node.body)
|
return parser._parse_type(node.body)
|
||||||
case p.VariableExpr(name=name):
|
case p.VariableExpr(name=name):
|
||||||
return p.BaseType(location=location, base=name, args=())
|
return p.BaseType(location=location, base=name, args=())
|
||||||
|
case p.SubscriptExpr(object=p.VariableExpr(name=name), index=arg):
|
||||||
|
args: tuple[p.MidasType, ...] = (
|
||||||
|
tuple(self._parse_type_from_expr(a) for a in arg.items)
|
||||||
|
if isinstance(arg, p.TupleExpr)
|
||||||
|
else (self._parse_type_from_expr(arg),)
|
||||||
|
)
|
||||||
|
return p.BaseType(location=location, base=name, args=args)
|
||||||
|
|
||||||
case _:
|
case _:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|||||||
@@ -362,9 +362,6 @@ def substitute_typevars(type: Type, substitutions: dict[str, Type]) -> Type:
|
|||||||
case UnknownType() | UnitType():
|
case UnknownType() | UnitType():
|
||||||
return type
|
return type
|
||||||
|
|
||||||
case TopType() | GenericType():
|
|
||||||
raise NotImplementedError(f"Unsupported type {type}")
|
|
||||||
|
|
||||||
# Ensure exhaustiveness
|
# Ensure exhaustiveness
|
||||||
case _:
|
case _:
|
||||||
assert_never(type)
|
assert_never(type)
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
import json
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from midas.ast.printer import MidasAstPrinter
|
|
||||||
from midas.lexer.midas import MidasLexer
|
|
||||||
from midas.lexer.token import Token
|
|
||||||
from midas.parser.midas import MidasParser
|
|
||||||
|
|
||||||
|
|
||||||
def test_midas():
|
|
||||||
# Midas type definitions
|
|
||||||
path: Path = Path("examples") / "00_syntax_prototype" / "03_custom_types_v2.midas"
|
|
||||||
definitions: str = path.read_text()
|
|
||||||
midas_lexer: MidasLexer = MidasLexer(definitions, path.name)
|
|
||||||
tokens: list[Token] = midas_lexer.process()
|
|
||||||
# print([f"{t.type.name}('{t.lexeme}')" for t in tokens])
|
|
||||||
with open("tokens.json", "w") as f:
|
|
||||||
json.dump([f"{t.type.name}('{t.lexeme}')" for t in tokens], f, indent=4)
|
|
||||||
|
|
||||||
parser = MidasParser(tokens)
|
|
||||||
parsed = parser.parse()
|
|
||||||
print(parsed)
|
|
||||||
for err in parser.errors:
|
|
||||||
print(err.get_report())
|
|
||||||
printer = MidasAstPrinter()
|
|
||||||
for stmt in parsed:
|
|
||||||
if stmt is None:
|
|
||||||
print("None")
|
|
||||||
continue
|
|
||||||
print(printer.print(stmt))
|
|
||||||
|
|
||||||
|
|
||||||
test_midas()
|
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
type Custom = float
|
type Custom = float
|
||||||
|
|
||||||
// Simple custom types with constraints
|
// Simple custom types with constraints
|
||||||
type Latitude = float where (-90 <= _ <= 90)
|
type Latitude = float where (-90 <= _ & _ <= 90)
|
||||||
type Longitude = float where (-180 <= _ <= 180)
|
type Longitude = float where (-180 <= _ & _ <= 180)
|
||||||
|
|
||||||
// Generic custom type (a Difference of T is derived from T, e.g. a difference of floats is a float
|
// Generic custom type (a Difference of T is derived from T, e.g. a difference of floats is a float
|
||||||
type Difference[T] = T
|
type Difference[T] = T
|
||||||
@@ -54,10 +54,10 @@ extend Person {
|
|||||||
prop name: str
|
prop name: str
|
||||||
|
|
||||||
// Property with an inline constraint
|
// Property with an inline constraint
|
||||||
prop age: Optional[int where (0 <= _ < 150)]
|
prop age: int where (0 <= _ & _ < 150)
|
||||||
|
|
||||||
// Property referencing a predicate
|
// Property referencing a predicate
|
||||||
prop height: float where StrictlyPositive
|
prop height: float where StrictlyPositive(_)
|
||||||
|
|
||||||
prop home: GeoLocation
|
prop home: GeoLocation
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,8 +187,8 @@
|
|||||||
"column": 38
|
"column": 38
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "LESS_EQUAL",
|
"type": "AND",
|
||||||
"lexeme": "<=",
|
"lexeme": "&",
|
||||||
"line": 5,
|
"line": 5,
|
||||||
"column": 39
|
"column": 39
|
||||||
},
|
},
|
||||||
@@ -196,25 +196,49 @@
|
|||||||
"type": "WHITESPACE",
|
"type": "WHITESPACE",
|
||||||
"lexeme": " ",
|
"lexeme": " ",
|
||||||
"line": 5,
|
"line": 5,
|
||||||
|
"column": 40
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "UNDERSCORE",
|
||||||
|
"lexeme": "_",
|
||||||
|
"line": 5,
|
||||||
"column": 41
|
"column": 41
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "WHITESPACE",
|
||||||
|
"lexeme": " ",
|
||||||
|
"line": 5,
|
||||||
|
"column": 42
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "LESS_EQUAL",
|
||||||
|
"lexeme": "<=",
|
||||||
|
"line": 5,
|
||||||
|
"column": 43
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "WHITESPACE",
|
||||||
|
"lexeme": " ",
|
||||||
|
"line": 5,
|
||||||
|
"column": 45
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "NUMBER",
|
"type": "NUMBER",
|
||||||
"lexeme": "90",
|
"lexeme": "90",
|
||||||
"line": 5,
|
"line": 5,
|
||||||
"column": 42
|
"column": 46
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "RIGHT_PAREN",
|
"type": "RIGHT_PAREN",
|
||||||
"lexeme": ")",
|
"lexeme": ")",
|
||||||
"line": 5,
|
"line": 5,
|
||||||
"column": 44
|
"column": 48
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "NEWLINE",
|
"type": "NEWLINE",
|
||||||
"lexeme": "\n",
|
"lexeme": "\n",
|
||||||
"line": 5,
|
"line": 5,
|
||||||
"column": 45
|
"column": 49
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "TYPE",
|
"type": "TYPE",
|
||||||
@@ -325,8 +349,8 @@
|
|||||||
"column": 40
|
"column": 40
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "LESS_EQUAL",
|
"type": "AND",
|
||||||
"lexeme": "<=",
|
"lexeme": "&",
|
||||||
"line": 6,
|
"line": 6,
|
||||||
"column": 41
|
"column": 41
|
||||||
},
|
},
|
||||||
@@ -334,25 +358,49 @@
|
|||||||
"type": "WHITESPACE",
|
"type": "WHITESPACE",
|
||||||
"lexeme": " ",
|
"lexeme": " ",
|
||||||
"line": 6,
|
"line": 6,
|
||||||
|
"column": 42
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "UNDERSCORE",
|
||||||
|
"lexeme": "_",
|
||||||
|
"line": 6,
|
||||||
"column": 43
|
"column": 43
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "WHITESPACE",
|
||||||
|
"lexeme": " ",
|
||||||
|
"line": 6,
|
||||||
|
"column": 44
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "LESS_EQUAL",
|
||||||
|
"lexeme": "<=",
|
||||||
|
"line": 6,
|
||||||
|
"column": 45
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "WHITESPACE",
|
||||||
|
"lexeme": " ",
|
||||||
|
"line": 6,
|
||||||
|
"column": 47
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "NUMBER",
|
"type": "NUMBER",
|
||||||
"lexeme": "180",
|
"lexeme": "180",
|
||||||
"line": 6,
|
"line": 6,
|
||||||
"column": 44
|
"column": 48
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "RIGHT_PAREN",
|
"type": "RIGHT_PAREN",
|
||||||
"lexeme": ")",
|
"lexeme": ")",
|
||||||
"line": 6,
|
"line": 6,
|
||||||
"column": 47
|
"column": 51
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "NEWLINE",
|
"type": "NEWLINE",
|
||||||
"lexeme": "\n",
|
"lexeme": "\n",
|
||||||
"line": 6,
|
"line": 6,
|
||||||
"column": 48
|
"column": 52
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "NEWLINE",
|
"type": "NEWLINE",
|
||||||
@@ -2240,22 +2288,40 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "IDENTIFIER",
|
"type": "IDENTIFIER",
|
||||||
"lexeme": "Optional",
|
"lexeme": "int",
|
||||||
"line": 57,
|
"line": 57,
|
||||||
"column": 15
|
"column": 15
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "LEFT_BRACKET",
|
"type": "WHITESPACE",
|
||||||
"lexeme": "[",
|
"lexeme": " ",
|
||||||
"line": 57,
|
"line": 57,
|
||||||
"column": 23
|
"column": 18
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "IDENTIFIER",
|
"type": "WHERE",
|
||||||
"lexeme": "int",
|
"lexeme": "where",
|
||||||
|
"line": 57,
|
||||||
|
"column": 19
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "WHITESPACE",
|
||||||
|
"lexeme": " ",
|
||||||
"line": 57,
|
"line": 57,
|
||||||
"column": 24
|
"column": 24
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "LEFT_PAREN",
|
||||||
|
"lexeme": "(",
|
||||||
|
"line": 57,
|
||||||
|
"column": 25
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "NUMBER",
|
||||||
|
"lexeme": "0",
|
||||||
|
"line": 57,
|
||||||
|
"column": 26
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "WHITESPACE",
|
"type": "WHITESPACE",
|
||||||
"lexeme": " ",
|
"lexeme": " ",
|
||||||
@@ -2263,8 +2329,8 @@
|
|||||||
"column": 27
|
"column": 27
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "WHERE",
|
"type": "LESS_EQUAL",
|
||||||
"lexeme": "where",
|
"lexeme": "<=",
|
||||||
"line": 57,
|
"line": 57,
|
||||||
"column": 28
|
"column": 28
|
||||||
},
|
},
|
||||||
@@ -2272,17 +2338,35 @@
|
|||||||
"type": "WHITESPACE",
|
"type": "WHITESPACE",
|
||||||
"lexeme": " ",
|
"lexeme": " ",
|
||||||
"line": 57,
|
"line": 57,
|
||||||
|
"column": 30
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "UNDERSCORE",
|
||||||
|
"lexeme": "_",
|
||||||
|
"line": 57,
|
||||||
|
"column": 31
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "WHITESPACE",
|
||||||
|
"lexeme": " ",
|
||||||
|
"line": 57,
|
||||||
|
"column": 32
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "AND",
|
||||||
|
"lexeme": "&",
|
||||||
|
"line": 57,
|
||||||
"column": 33
|
"column": 33
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "LEFT_PAREN",
|
"type": "WHITESPACE",
|
||||||
"lexeme": "(",
|
"lexeme": " ",
|
||||||
"line": 57,
|
"line": 57,
|
||||||
"column": 34
|
"column": 34
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "NUMBER",
|
"type": "UNDERSCORE",
|
||||||
"lexeme": "0",
|
"lexeme": "_",
|
||||||
"line": 57,
|
"line": 57,
|
||||||
"column": 35
|
"column": 35
|
||||||
},
|
},
|
||||||
@@ -2293,8 +2377,8 @@
|
|||||||
"column": 36
|
"column": 36
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "LESS_EQUAL",
|
"type": "LESS",
|
||||||
"lexeme": "<=",
|
"lexeme": "<",
|
||||||
"line": 57,
|
"line": 57,
|
||||||
"column": 37
|
"column": 37
|
||||||
},
|
},
|
||||||
@@ -2302,55 +2386,25 @@
|
|||||||
"type": "WHITESPACE",
|
"type": "WHITESPACE",
|
||||||
"lexeme": " ",
|
"lexeme": " ",
|
||||||
"line": 57,
|
"line": 57,
|
||||||
"column": 39
|
"column": 38
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "UNDERSCORE",
|
|
||||||
"lexeme": "_",
|
|
||||||
"line": 57,
|
|
||||||
"column": 40
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "WHITESPACE",
|
|
||||||
"lexeme": " ",
|
|
||||||
"line": 57,
|
|
||||||
"column": 41
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "LESS",
|
|
||||||
"lexeme": "<",
|
|
||||||
"line": 57,
|
|
||||||
"column": 42
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "WHITESPACE",
|
|
||||||
"lexeme": " ",
|
|
||||||
"line": 57,
|
|
||||||
"column": 43
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "NUMBER",
|
"type": "NUMBER",
|
||||||
"lexeme": "150",
|
"lexeme": "150",
|
||||||
"line": 57,
|
"line": 57,
|
||||||
"column": 44
|
"column": 39
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "RIGHT_PAREN",
|
"type": "RIGHT_PAREN",
|
||||||
"lexeme": ")",
|
"lexeme": ")",
|
||||||
"line": 57,
|
"line": 57,
|
||||||
"column": 47
|
"column": 42
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "RIGHT_BRACKET",
|
|
||||||
"lexeme": "]",
|
|
||||||
"line": 57,
|
|
||||||
"column": 48
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "NEWLINE",
|
"type": "NEWLINE",
|
||||||
"lexeme": "\n",
|
"lexeme": "\n",
|
||||||
"line": 57,
|
"line": 57,
|
||||||
"column": 49
|
"column": 43
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "NEWLINE",
|
"type": "NEWLINE",
|
||||||
@@ -2442,11 +2496,29 @@
|
|||||||
"line": 60,
|
"line": 60,
|
||||||
"column": 30
|
"column": 30
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "LEFT_PAREN",
|
||||||
|
"lexeme": "(",
|
||||||
|
"line": 60,
|
||||||
|
"column": 46
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "UNDERSCORE",
|
||||||
|
"lexeme": "_",
|
||||||
|
"line": 60,
|
||||||
|
"column": 47
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "RIGHT_PAREN",
|
||||||
|
"lexeme": ")",
|
||||||
|
"line": 60,
|
||||||
|
"column": 48
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "NEWLINE",
|
"type": "NEWLINE",
|
||||||
"lexeme": "\n",
|
"lexeme": "\n",
|
||||||
"line": 60,
|
"line": 60,
|
||||||
"column": 46
|
"column": 49
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "NEWLINE",
|
"type": "NEWLINE",
|
||||||
@@ -2544,7 +2616,7 @@
|
|||||||
"constraint": {
|
"constraint": {
|
||||||
"_type": "GroupingExpr",
|
"_type": "GroupingExpr",
|
||||||
"expr": {
|
"expr": {
|
||||||
"_type": "BinaryExpr",
|
"_type": "LogicalExpr",
|
||||||
"left": {
|
"left": {
|
||||||
"_type": "BinaryExpr",
|
"_type": "BinaryExpr",
|
||||||
"left": {
|
"left": {
|
||||||
@@ -2560,6 +2632,12 @@
|
|||||||
"_type": "WildcardExpr"
|
"_type": "WildcardExpr"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"operator": "&",
|
||||||
|
"right": {
|
||||||
|
"_type": "BinaryExpr",
|
||||||
|
"left": {
|
||||||
|
"_type": "WildcardExpr"
|
||||||
|
},
|
||||||
"operator": "<=",
|
"operator": "<=",
|
||||||
"right": {
|
"right": {
|
||||||
"_type": "LiteralExpr",
|
"_type": "LiteralExpr",
|
||||||
@@ -2568,6 +2646,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_type": "TypeStmt",
|
"_type": "TypeStmt",
|
||||||
@@ -2582,7 +2661,7 @@
|
|||||||
"constraint": {
|
"constraint": {
|
||||||
"_type": "GroupingExpr",
|
"_type": "GroupingExpr",
|
||||||
"expr": {
|
"expr": {
|
||||||
"_type": "BinaryExpr",
|
"_type": "LogicalExpr",
|
||||||
"left": {
|
"left": {
|
||||||
"_type": "BinaryExpr",
|
"_type": "BinaryExpr",
|
||||||
"left": {
|
"left": {
|
||||||
@@ -2598,6 +2677,12 @@
|
|||||||
"_type": "WildcardExpr"
|
"_type": "WildcardExpr"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"operator": "&",
|
||||||
|
"right": {
|
||||||
|
"_type": "BinaryExpr",
|
||||||
|
"left": {
|
||||||
|
"_type": "WildcardExpr"
|
||||||
|
},
|
||||||
"operator": "<=",
|
"operator": "<=",
|
||||||
"right": {
|
"right": {
|
||||||
"_type": "LiteralExpr",
|
"_type": "LiteralExpr",
|
||||||
@@ -2606,6 +2691,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"_type": "TypeStmt",
|
"_type": "TypeStmt",
|
||||||
@@ -3013,13 +3099,6 @@
|
|||||||
"kind": "PROPERTY",
|
"kind": "PROPERTY",
|
||||||
"name": "age",
|
"name": "age",
|
||||||
"type": {
|
"type": {
|
||||||
"_type": "GenericType",
|
|
||||||
"type": {
|
|
||||||
"_type": "NamedType",
|
|
||||||
"name": "Optional"
|
|
||||||
},
|
|
||||||
"args": [
|
|
||||||
{
|
|
||||||
"_type": "ConstraintType",
|
"_type": "ConstraintType",
|
||||||
"type": {
|
"type": {
|
||||||
"_type": "NamedType",
|
"_type": "NamedType",
|
||||||
@@ -3028,7 +3107,7 @@
|
|||||||
"constraint": {
|
"constraint": {
|
||||||
"_type": "GroupingExpr",
|
"_type": "GroupingExpr",
|
||||||
"expr": {
|
"expr": {
|
||||||
"_type": "BinaryExpr",
|
"_type": "LogicalExpr",
|
||||||
"left": {
|
"left": {
|
||||||
"_type": "BinaryExpr",
|
"_type": "BinaryExpr",
|
||||||
"left": {
|
"left": {
|
||||||
@@ -3040,6 +3119,12 @@
|
|||||||
"_type": "WildcardExpr"
|
"_type": "WildcardExpr"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"operator": "&",
|
||||||
|
"right": {
|
||||||
|
"_type": "BinaryExpr",
|
||||||
|
"left": {
|
||||||
|
"_type": "WildcardExpr"
|
||||||
|
},
|
||||||
"operator": "<",
|
"operator": "<",
|
||||||
"right": {
|
"right": {
|
||||||
"_type": "LiteralExpr",
|
"_type": "LiteralExpr",
|
||||||
@@ -3048,7 +3133,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -3062,8 +3146,17 @@
|
|||||||
"name": "float"
|
"name": "float"
|
||||||
},
|
},
|
||||||
"constraint": {
|
"constraint": {
|
||||||
|
"_type": "CallExpr",
|
||||||
|
"callee": {
|
||||||
"_type": "VariableExpr",
|
"_type": "VariableExpr",
|
||||||
"name": "StrictlyPositive"
|
"name": "StrictlyPositive"
|
||||||
|
},
|
||||||
|
"arguments": [
|
||||||
|
{
|
||||||
|
"_type": "WildcardExpr"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"keywords": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user