-
-
Notifications
You must be signed in to change notification settings - Fork 356
Description
Currently when running roc check on interface files that import a platform or package eg import [pf.Stdout] the checking will fail because we don't know where to get the package or platform from.
After discussing here https://roc.zulipchat.com/#narrow/stream/304641-ideas/topic/package.20shorthands.20when.20compiling.20interface.20modules
We concluded we should be able to find the file that the interface is imported by following some simple rules:
"app, package, and platform modules can only import other modules if they are named exactly main.roc, but otherwise they can be named anything. Normal modules can be named anything and can still import each other."
"the default file to look for is named main.roc, but that can be configured in the editor"
This means, the roc cli and the language server can make the following assumptions:
- Scripts, which would regularly not be named "main.roc" cannot have imports and this doesn't require changing language server settings. We can assume, as the language server or roc cli, anything not named "main.roc"(or your configured main name) doesn't have imports.
- If we don't see a "main.roc"(or your configured main name) in the current directory, in a valid project we should expect to be able to walk up directories to find one.
So this requires the following changes:
- When running
roc checkagainst an interface with a package import we should look for main.roc and use it's package versions to resolve that package. The cli should allow the user to specify this if they wish if they are using a different name for their main file. eg:roc check myInterface.roc --main app - The language server should make any changes needed to ensure this works there too.
- The language server should have an option to set the name of the file that we expect to be the main file. So if instead of main.roc someone wants "app.roc" they can configure that.
- Adjust or remove the error message added here: https://github.com/roc-lang/roc/pull/6361/commits