Merge pull request #2393 from rtfeldman/i/2343

Generate unique symbols for shadowing identifiers
This commit is contained in:
Folkert de Vries 2022-01-24 11:49:51 +01:00 committed by GitHub
commit 6dd769aa38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 89 additions and 35 deletions

View file

@ -1980,12 +1980,12 @@ fn pattern_to_when<'a>(
// for underscore we generate a dummy Symbol
(env.unique_symbol(), body)
}
Shadowed(region, loc_ident) => {
Shadowed(region, loc_ident, new_symbol) => {
let error = roc_problem::can::RuntimeError::Shadowing {
original_region: *region,
shadow: loc_ident.clone(),
};
(env.unique_symbol(), Loc::at_zero(RuntimeError(error)))
(*new_symbol, Loc::at_zero(RuntimeError(error)))
}
UnsupportedPattern(region) => {
@ -7653,7 +7653,7 @@ fn from_can_pattern_help<'a>(
}
}
StrLiteral(v) => Ok(Pattern::StrLiteral(v.clone())),
Shadowed(region, ident) => Err(RuntimeError::Shadowing {
Shadowed(region, ident, _new_symbol) => Err(RuntimeError::Shadowing {
original_region: *region,
shadow: ident.clone(),
}),