mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
don't add guarded record fields into scope
This commit is contained in:
parent
85e2cf4465
commit
fd7ca5bcc9
8 changed files with 196 additions and 79 deletions
|
@ -57,10 +57,13 @@ impl Scope {
|
|||
pub fn lookup(&mut self, ident: &Ident, region: Region) -> Result<Symbol, RuntimeError> {
|
||||
match self.idents.get(ident) {
|
||||
Some((symbol, _)) => Ok(*symbol),
|
||||
None => Err(RuntimeError::LookupNotInScope(Located {
|
||||
region,
|
||||
value: ident.clone().into(),
|
||||
})),
|
||||
None => Err(RuntimeError::LookupNotInScope(
|
||||
Located {
|
||||
region,
|
||||
value: ident.clone().into(),
|
||||
},
|
||||
self.idents.keys().map(|v| v.as_ref().into()).collect(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,6 +110,14 @@ impl Scope {
|
|||
}
|
||||
}
|
||||
|
||||
/// Ignore an identifier.
|
||||
///
|
||||
/// Used for record guards like { x: Just _ }
|
||||
pub fn ignore(&mut self, ident: Ident, all_ident_ids: &mut IdentIds) -> Symbol {
|
||||
let ident_id = all_ident_ids.add(ident.into());
|
||||
Symbol::new(self.home, ident_id)
|
||||
}
|
||||
|
||||
/// Import a Symbol from another module into this module's top-level scope.
|
||||
///
|
||||
/// Returns Err if this would shadow an existing ident, including the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue