mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 22:34:45 +00:00
🐛️ Handle unimported modules properly
helpful error, not panic! Closes #2422
This commit is contained in:
parent
b5b26eabc9
commit
4d10c22442
7 changed files with 93 additions and 32 deletions
|
@ -161,10 +161,37 @@ pub enum RuntimeError {
|
|||
region: Region,
|
||||
exposed_values: Vec<Lowercase>,
|
||||
},
|
||||
/// A module was referenced, but hasn't been imported anywhere in the program
|
||||
///
|
||||
/// An example would be:
|
||||
/// ```roc
|
||||
/// app "hello"
|
||||
/// packages { pf: "platform" }
|
||||
/// imports [ pf.Stdout]
|
||||
/// provides [ main ] to pf
|
||||
///
|
||||
/// main : Task.Task {} [] // Task isn't imported!
|
||||
/// main = Stdout.line "I'm a Roc application!"
|
||||
/// ```
|
||||
ModuleNotImported {
|
||||
/// The name of the module that was referenced
|
||||
module_name: ModuleName,
|
||||
/// A list of modules which *have* been imported
|
||||
imported_modules: MutSet<Box<str>>,
|
||||
/// Where the problem occured
|
||||
region: Region,
|
||||
/// Whether or not the module exists at all
|
||||
///
|
||||
/// This is used to suggest that the user import the module, as opposed to fix a
|
||||
/// typo in the spelling. For example, if the user typed `Task`, and the platform
|
||||
/// exposes a `Task` module that hasn't been imported, we can sugguest that they
|
||||
/// add the import statement.
|
||||
///
|
||||
/// On the other hand, if the user typed `Tesk`, they might want to check their
|
||||
/// spelling.
|
||||
///
|
||||
/// If unsure, this should be set to `false`
|
||||
module_exists: bool,
|
||||
},
|
||||
InvalidPrecedence(PrecedenceProblem, Region),
|
||||
MalformedIdentifier(Box<str>, roc_parse::ident::BadIdent, Region),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue