Skip to content
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

Closed
wants to merge 129 commits into from
Closed

Pr lazysemcheck exp4 #809

wants to merge 129 commits into from

Conversation

timotheecour
Copy link
Owner

No description provided.

@@ -869,6 +872,10 @@ type
bitsize*: int
alignment*: int # for alignment
else: nil
lazyDecl*: PSym
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this required?

Copy link
Owner Author

@timotheecour timotheecour Sep 3, 2021

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.

Copy link

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

Copy link
Owner Author

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

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good points.

Araq and others added 27 commits September 4, 2021 08:18
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>
@timotheecour
Copy link
Owner Author

closing because the PR was moved to nim-lang#18818

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants