dfinity / vscode-motoko

Motoko language support for VS Code.
Apache License 2.0
42 stars 16 forks source link

Import error at top line of each file when writing a module #90

Closed ByronBecker closed 1 year ago

ByronBecker commented 1 year ago

When developing a module, I often find that the top line of the file has the following error, regardless of if that line contains an import or not.

Screen Shot 2022-11-02 at 20 42 50

Hovering over red underline shows the following error:

Screen Shot 2022-11-02 at 20 43 11.

rvanasa commented 1 year ago

Does the .vessel directory contain the file which is mentioned in the error message?

Also, does this happen everywhere or just for a specific project? I'm currently looking for a way to reproduce this on my end.

ByronBecker commented 1 year ago

I'm currently looking for a way to reproduce this on my end.

Sure, I find the https://github.com/ByronBecker/motoko-library-template is a decent reproducible example. Both the src/Library.mo and test/Test.mo files have this issue.

rvanasa commented 1 year ago

This repository works as expected for me (just shows errors related to the matchers library, which is a known bug with nested Vessel projects), so I'm guessing this has something to do with the .vessel directory being out of sync with the package-set.

Does this persist after deleting .vessel and restarting the language server?

ByronBecker commented 1 year ago

Thanks! It looks like doing that resolved the issue is question.

I now have a different issue, where (in the same project), it seems like in the test directory it's not able to pick up on matchers as an import (vessel imports).

Screen Shot 2022-11-03 at 11 31 00

However, in a different project that I'm working on based off of the same template and vessel imports, this problem doesn't appear.

Screen Shot 2022-11-03 at 11 40 16

Is there some sort of caching going on, or a command I can run to force the program to re-check imported packages with the language server?

ByronBecker commented 1 year ago

@rvanasa, since the original issue seems to be fixed I'll close this issue for upkeep - but if you want to discuss the follow-up issue in the comment directly above ☝️ we can do so here, or via the forums (whatever you prefer)

rvanasa commented 1 year ago

Sounds good. I'll open a new issue to address nested Vessel projects, since this seems to be the most frequent blocker in the extension right now.

rvanasa commented 1 year ago

Reopened #66, which appears to be the same issue.