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

confusion of forvar type when supplied as typed macro argument #1211

Open
disruptek opened this issue Feb 27, 2024 · 2 comments
Open

confusion of forvar type when supplied as typed macro argument #1211

disruptek opened this issue Feb 27, 2024 · 2 comments
Labels
bug Something isn't working compiler/sem Related to semantic-analysis system of the compiler

Comments

@disruptek
Copy link
Contributor

I know, I know. This is, at present, a full-fat repro. 😉

Example

This code only runs on Linux.

https://github.com/disruptek/insideout/blob/erasure/tests/6/tbillion2.nim#L49

  block:
    var pool = newPool(ContinuationWaiter)
    for queue in queues.items:  # seq[Mailbox[Continuation]]
      #assert queue is AtomicRef[MailboxObj[Continuation]]
      assert queue is Mailbox[Continuation]
      pause queue
      when true:
        # nimskull says Error: type mismatch: got <AtomicRef>
        pool.add: spawn(ContinuationWaiter, queue)
      elif true:
        # nimskull says Error: type mismatch: got <AtomicRef>
        pool.add: ContinuationWaiter.call(queue)
      elif true:
        # nimskull likes this one
        pool.add: spawn(ContinuationWaiter, Mailbox[Continuation] queue)
      elif true:
        # nimskull likes this one, too
        pool.add: ContinuationWaiter.call(Mailbox[Continuation] queue)

The call macro from cps, which turns a Callback and varargs[typed] into a Continuation, seems to be losing track of the fact that queue is a Mailbox[Continuation] and not merely AtomicRef[MailboxObj[Continuation]]. The code works in old nim and it works if you remove the iterator.

To reproduce...

$ git clone --branch erasure https://github.com/disruptek/insideout
$ cd insideout
# setup a nim.cfg and then...
$ nimph doctor
$ nim c --define:useMalloc --gc:arc --threads:on --panics:on tests/6/tbillion2.nim

Actual Output

tbillion2.nim(49, 25) Error: type mismatch: got <AtomicRef>
but expected one of:
proc (box`gensym7: Mailbox[spec.Continuation]): Continuation{.nimcall.}

Expected Output

Additional Information

Nimskull Compiler Version 0.1.0-dev.21241 [linux: amd64]

Source hash: 9be395f752aa23c01e7214987e0b2386609ae821
Source date: 2024-02-26

active boot switches: -d:release -d:danger⏎
@saem
Copy link
Collaborator

saem commented Feb 27, 2024

Thanks for filing this, I'm going to do a quick semantic trace on this to get an initial triage.

@saem
Copy link
Collaborator

saem commented Feb 27, 2024

Pretty sure this is the same issue as #1181, and should be restested once #1192 is merged

@zerbina zerbina added bug Something isn't working compiler/sem Related to semantic-analysis system of the compiler labels Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler/sem Related to semantic-analysis system of the compiler
Projects
None yet
Development

No branches or pull requests

3 participants