mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 07:14:46 +00:00
report unexposed values
This commit is contained in:
parent
802f821782
commit
dc5eec189c
8 changed files with 114 additions and 13 deletions
|
@ -344,6 +344,11 @@ fn pretty_runtime_error<'b>(
|
|||
unreachable!("")
|
||||
}
|
||||
|
||||
RuntimeError::UnresolvedTypeVar | RuntimeError::ErroneousType => {
|
||||
// only generated during layout generation
|
||||
unreachable!("")
|
||||
}
|
||||
|
||||
RuntimeError::Shadowing {
|
||||
original_region,
|
||||
shadow,
|
||||
|
@ -443,7 +448,20 @@ fn pretty_runtime_error<'b>(
|
|||
RuntimeError::UnsupportedPattern(_) => {
|
||||
todo!("unsupported patterns are currently not parsed!")
|
||||
}
|
||||
RuntimeError::ValueNotExposed { .. } => todo!("value not exposed"),
|
||||
RuntimeError::ValueNotExposed { module_name, ident, region } => {
|
||||
alloc.stack(vec![
|
||||
alloc.concat(vec![
|
||||
alloc.reflow("The "),
|
||||
alloc.module_name(module_name),
|
||||
alloc.reflow(" module does not expose a "),
|
||||
alloc.string(ident.to_string()),
|
||||
alloc.reflow(" value:"),
|
||||
]),
|
||||
alloc.region(region),
|
||||
])
|
||||
}
|
||||
|
||||
|
||||
RuntimeError::ModuleNotImported {
|
||||
module_name,
|
||||
imported_modules,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use inlinable_string::InlinableString;
|
||||
use roc_module::ident::Ident;
|
||||
use roc_module::ident::{Lowercase, TagName, Uppercase};
|
||||
use roc_module::ident::{Lowercase, ModuleName, TagName, Uppercase};
|
||||
use roc_module::symbol::{Interns, ModuleId, Symbol};
|
||||
use std::fmt;
|
||||
use std::path::PathBuf;
|
||||
|
@ -316,6 +316,17 @@ impl<'a> RocDocAllocator<'a> {
|
|||
self.text(name).annotate(Annotation::Module)
|
||||
}
|
||||
|
||||
pub fn module_name(&'a self, name: ModuleName) -> DocBuilder<'a, Self, Annotation> {
|
||||
let name = if name.is_empty() {
|
||||
// Render the app module as "app"
|
||||
"app".to_string()
|
||||
} else {
|
||||
name.as_str().to_string()
|
||||
};
|
||||
|
||||
self.text(name).annotate(Annotation::Module)
|
||||
}
|
||||
|
||||
pub fn inlinable_string(&'a self, s: InlinableString) -> DocBuilder<'a, Self, Annotation> {
|
||||
self.text(format!("{}", s)).annotate(Annotation::Module)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue