Introdue ability member names before other value names

This commit is contained in:
Ayaz Hafiz 2022-07-18 13:32:35 -04:00
parent e672ce9ebd
commit 96b32c36cb
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
3 changed files with 118 additions and 73 deletions

View file

@ -5,7 +5,7 @@ use crate::num::{
finish_parsing_base, finish_parsing_float, finish_parsing_num, FloatBound, IntBound, NumBound,
ParsedNumResult,
};
use crate::scope::Scope;
use crate::scope::{PendingAbilitiesInScope, Scope};
use roc_module::ident::{Ident, Lowercase, TagName};
use roc_module::symbol::Symbol;
use roc_parse::ast::{self, StrLiteral, StrSegment};
@ -179,6 +179,7 @@ pub fn canonicalize_def_header_pattern<'a>(
env: &mut Env<'a>,
var_store: &mut VarStore,
scope: &mut Scope,
pending_abilities_in_scope: &PendingAbilitiesInScope,
output: &mut Output,
pattern_type: PatternType,
pattern: &ast::Pattern<'a>,
@ -189,7 +190,11 @@ pub fn canonicalize_def_header_pattern<'a>(
match pattern {
// Identifiers that shadow ability members may appear (and may only appear) at the header of a def.
Identifier(name) => {
match scope.introduce_or_shadow_ability_member((*name).into(), region) {
match scope.introduce_or_shadow_ability_member(
pending_abilities_in_scope,
(*name).into(),
region,
) {
Ok((symbol, shadowing_ability_member)) => {
let can_pattern = match shadowing_ability_member {
// A fresh identifier.