mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
wip
This commit is contained in:
parent
9e02537ebb
commit
0a9989e75f
7 changed files with 61 additions and 30 deletions
|
@ -91,6 +91,7 @@ pub enum Declaration {
|
|||
Vec<Located<Ident>>,
|
||||
Vec<(Region /* pattern */, Region /* expr */)>,
|
||||
),
|
||||
Builtin(Def),
|
||||
}
|
||||
|
||||
impl Declaration {
|
||||
|
@ -100,6 +101,7 @@ impl Declaration {
|
|||
Declare(_) => 1,
|
||||
DeclareRec(defs) => defs.len(),
|
||||
InvalidCycle(_, _) => 0,
|
||||
Builtin(_) => 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1249,6 +1251,10 @@ fn decl_to_let(
|
|||
Declaration::InvalidCycle(symbols, regions) => {
|
||||
Expr::RuntimeError(RuntimeError::CircularDef(symbols, regions))
|
||||
}
|
||||
Declaration::Builtin(_) => {
|
||||
// Builtins should only be added to top-level decls, not to let-exprs!
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -151,6 +151,7 @@ pub fn canonicalize_module_defs<'a>(
|
|||
(Ok(declarations), output) => {
|
||||
use crate::def::Declaration::*;
|
||||
|
||||
// Record the variables for all exposed symbols.
|
||||
let mut exposed_vars_by_symbol = Vec::with_capacity(exposed_symbols.len());
|
||||
|
||||
for decl in declarations.iter() {
|
||||
|
@ -193,6 +194,14 @@ pub fn canonicalize_module_defs<'a>(
|
|||
InvalidCycle(identifiers, _) => {
|
||||
panic!("TODO gracefully handle potentially attempting to expose invalid cyclic defs {:?}" , identifiers);
|
||||
}
|
||||
Builtin(def) => {
|
||||
// Builtins cannot be exposed in module declarations.
|
||||
// This should never happen!
|
||||
debug_assert!(def
|
||||
.pattern_vars
|
||||
.iter()
|
||||
.all(|(symbol, _)| !exposed_symbols.contains(symbol)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue