-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pr lazysemcheck exp4 #809
Pr lazysemcheck exp4 #809
Conversation
5df62a3
to
400302f
Compare
@@ -869,6 +872,10 @@ type | |||
bitsize*: int | |||
alignment*: int # for alignment | |||
else: nil | |||
lazyDecl*: PSym |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it turns out, surprisingly, that so far the hardest thing to address was the case of existing fwd declarations, and making sure everything keeps working when those are present (note that they're not needed after this PR, but the code should still work when those are defined in existing code)
the difficulty is:
proc fn(a: int) = discard # distractor
proc fn(a: Foo, b = bar()) # fwd decl
proc fn(a: Foo, b = bar()) = discard # impl decl
lazy semcheck registers those 3 overloads without any semcheck (in particular bar doesn't need semchecking yet), and I don't know any way to know that 2 and 3 represent same symbol until semcheck happens, which happens once some code refers to fn
, at which point the semcheck for each overload (in the same scope only) is done
back to your question:
I'm using lazyDecl
to resolve an apparent openSymChoice into just a single Psym in cases like this, see regression test:
block:
proc fnAux(): int
proc fn8(r = fnAux) = discard
proc fnAux(): int = discard
fn8()
i detect that n[1].lazyDecl = n[0]
(1 is a fwd declaration of the other) without having to re-compute that the overloads have same type, and should collapse.
I could use a side-channel to store lazyDecl
though, in finalized PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I suspected, but why not just ignore forward decls? These are the ones without body that are not .magic or .importc/cpp/js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't see how these can be ignored, for several reasons; one of those reasons is that fwd decls can contain more information than the implementation:
proc baz(): int = 12
proc fn1*(a: int, b = baz()) {.gcsafe.}
proc fn1(a: int, b: int) = echo (a,b)
if you ignore the fwd decl, you'd miss:
- gcsafe
- the export
- the optional param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, good points.
400302f
to
f516fb6
Compare
nim-lang#18796) * we need something better than warningAsError for effect handling violations
* Assignments, which would accidentally create global variables, instead throw an error in strict mode * Assignment to a getter-only property Co-authored-by: Sven Keller <s.keller@cortona.de>
* remove channels * test
* add weave to important packages * Update testament/important_packages.nim
* fixes nim-lang#12642 * update important packages; refs nim-lang#18804 * fixes nim-lang#18805; refs nim-lang#18806 * fixes a regression * Update testament/categories.nim Co-authored-by: flywind <xzsflywind@gmail.com> * progress * progress Co-authored-by: flywind <xzsflywind@gmail.com>
* Fixes implicit and explicit generics * moved block logic into 'maybeInstantiateGeneric' * Added more tests * Update compiler/semexprs.nim Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
…ions properly restored with determineType2
… for gensym routines)
2cdeaaf
to
27e68f6
Compare
closing because the PR was moved to nim-lang#18818 |
No description provided.