Comments (2)
Thanks for the report... It looks like this was caused by 6ce212a. That prevents code like:
import __static__
class C:
def __init__(self):
self.x = 42
def f():
global a
a = 42
a = C()
f()
print(a.x)
From crashing, but we'll need to come up with a better solution here and retain the implicit type information while disallowing the conflicting assignment. We do report the invalid assignment if def f
comes after the assignment to a
so it's probably just adjusting how our passes run or adding a new pass.
from cinder.
We've come up with some other interesting examples:
class A: pass
class B(A): pass
def f():
global x
x = A() # this assignment should be ok
def g(arg: B): pass
x: A = B()
f()
g(x) # should be a TypedSyntaxError, with or without `f()` (or even the definition of `f`)
And we've looked at what Pyre does here as well. Both Pyre and static Python have a notion of inferred type as well as the declared type. In some annotated cases like "x = 42" it seems that there ends up being an inferred type of Literal[42]
and a declared type of int
.
Currently we only end up with an inferred type, and then we're turning that into dynamic. We probably need to more closely mimic what Pyre is doing for getting a declared type in these situations, and then drop the inferred type. And we need to understand more when we should treat the inferred type as declared.
We also may be able to do this in limited scenarios, e.g. where there are no references to global
in the module, where we know the value won't change (because the module is known to be immutable).
And we may need to add an extra pass in to accomodate this as well.
Unfortunately this will take a little while to get to!
from cinder.
Related Issues (20)
- Type errors in deltablue_static HOT 3
- Build error: C++20 ambiguous & forming offset 4 is out of the bounds HOT 1
- fannkuch benchmark & implicit returns
- Error compiling with `--with-lto` -- undefined reference to `vtable for strictmod::objects::StrictExceptionObject`
- Cannot install insightface by python-cinder HOT 2
- RuntimeError: Failed to initialize CinderX HOT 3
- could not find symtab HOT 4
- Outdated instructions in python-build-env? HOT 5
- "Ghost" arguments are being passed to method calls! HOT 6
- add README for benchmarks HOT 7
- questions about CheckedDict and unknown types HOT 5
- Benchmark Cinder vs. Cpython performance; improve pipeline and performance of the Cinder build HOT 15
- 15 failing tests fail when running `make test` on a Mac HOT 1
- build error: listnode.gcda missing-profile HOT 3
- Cinder vs. Python 3.11 HOT 9
- can't compare double to Literal HOT 1
- nonsensical TypeError from "-X jit -m compile --static" HOT 3
- No pattern found for opcode Fadd: Xxr HOT 2
- HPy support HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cinder.