mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 08:11:12 +00:00
Drop some unused pattern Variables
This commit is contained in:
parent
4afa116156
commit
03f5896e89
3 changed files with 15 additions and 17 deletions
|
@ -457,10 +457,8 @@ fn canonicalize_def<'a>(
|
|||
// implicitly, that is the case here too
|
||||
let mut fname = "invalid name".to_string();
|
||||
|
||||
if let (
|
||||
&ast::Pattern::Identifier(ref name),
|
||||
&Pattern::Identifier(_, ref defined_symbol),
|
||||
) = (&loc_pattern.value, &loc_can_pattern.value)
|
||||
if let (&ast::Pattern::Identifier(ref name), &Pattern::Identifier(ref defined_symbol)) =
|
||||
(&loc_pattern.value, &loc_can_pattern.value)
|
||||
{
|
||||
fname = (*name).to_string();
|
||||
env.tailcallable_symbol = Some(defined_symbol.clone());
|
||||
|
@ -531,7 +529,7 @@ fn canonicalize_def<'a>(
|
|||
// Only defs of the form (foo = ...) can be closure declarations or self tail calls.
|
||||
if let (
|
||||
&ast::Pattern::Identifier(ref _name),
|
||||
&Pattern::Identifier(_, ref defined_symbol),
|
||||
&Pattern::Identifier(ref defined_symbol),
|
||||
&Closure(ref symbol, _, ref arguments, ref body),
|
||||
) = (
|
||||
&loc_pattern.value,
|
||||
|
@ -675,7 +673,7 @@ fn canonicalize_def<'a>(
|
|||
|
||||
if let (
|
||||
&ast::Pattern::Identifier(ref _name),
|
||||
&Pattern::Identifier(_, ref defined_symbol),
|
||||
&Pattern::Identifier(ref defined_symbol),
|
||||
) = (&loc_pattern.value, &loc_can_pattern.value)
|
||||
{
|
||||
env.tailcallable_symbol = Some(defined_symbol.clone());
|
||||
|
@ -714,7 +712,7 @@ fn canonicalize_def<'a>(
|
|||
// Only defs of the form (foo = ...) can be closure declarations or self tail calls.
|
||||
if let (
|
||||
&ast::Pattern::Identifier(ref _name),
|
||||
&Pattern::Identifier(_, ref defined_symbol),
|
||||
&Pattern::Identifier(ref defined_symbol),
|
||||
&Closure(ref symbol, _, ref arguments, ref body),
|
||||
) = (
|
||||
&loc_pattern.value,
|
||||
|
|
|
@ -16,15 +16,15 @@ use im_rc::Vector;
|
|||
/// codegen can generate a runtime error if this pattern is reached.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Pattern {
|
||||
Identifier(Variable, Symbol),
|
||||
Identifier(Symbol),
|
||||
Tag(Variable, Symbol),
|
||||
/// TODO replace regular Tag with this
|
||||
AppliedTag(Variable, Symbol, Vec<Located<Pattern>>),
|
||||
IntLiteral(i64),
|
||||
FloatLiteral(f64),
|
||||
ExactString(Box<str>),
|
||||
EmptyRecordLiteral(Variable),
|
||||
Underscore(Variable),
|
||||
EmptyRecordLiteral,
|
||||
Underscore,
|
||||
|
||||
// Runtime Exceptions
|
||||
Shadowed(Located<Ident>),
|
||||
|
@ -40,7 +40,7 @@ pub fn symbols_from_pattern(pattern: &Pattern) -> Vec<Symbol> {
|
|||
}
|
||||
|
||||
pub fn symbols_from_pattern_help(pattern: &Pattern, symbols: &mut Vec<Symbol>) {
|
||||
if let Pattern::Identifier(_, symbol) = pattern {
|
||||
if let Pattern::Identifier(symbol) = pattern {
|
||||
symbols.push(symbol.clone());
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ pub fn canonicalize_pattern<'a>(
|
|||
.insert(new_ident.clone(), symbol_and_region.clone());
|
||||
shadowable_idents.insert(new_ident, symbol_and_region);
|
||||
|
||||
Pattern::Identifier(var_store.fresh(), symbol)
|
||||
Pattern::Identifier(symbol)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ pub fn canonicalize_pattern<'a>(
|
|||
},
|
||||
|
||||
&Underscore => match pattern_type {
|
||||
CaseBranch | FunctionArg => Pattern::Underscore(var_store.fresh()),
|
||||
CaseBranch | FunctionArg => Pattern::Underscore,
|
||||
ptype @ Assignment | ptype @ TopLevelDef => unsupported_pattern(env, ptype, region),
|
||||
},
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ fn canonicalize_pattern(
|
|||
use crate::types::PatternCategory;
|
||||
|
||||
match &pattern.value {
|
||||
Identifier(_, symbol) => {
|
||||
Identifier(symbol) => {
|
||||
state.headers.insert(
|
||||
symbol.clone(),
|
||||
Located {
|
||||
|
@ -104,11 +104,11 @@ fn canonicalize_pattern(
|
|||
));
|
||||
}
|
||||
|
||||
Tag(_, _) | AppliedTag(_, _, _) | EmptyRecordLiteral(_) => {
|
||||
Tag(_, _) | AppliedTag(_, _, _) | EmptyRecordLiteral => {
|
||||
panic!("TODO add_constraints for {:?}", pattern);
|
||||
}
|
||||
|
||||
Underscore(_) | Shadowed(_) | UnsupportedPattern(_) => {
|
||||
Underscore | Shadowed(_) | UnsupportedPattern(_) => {
|
||||
// no constraints
|
||||
}
|
||||
}
|
||||
|
@ -583,7 +583,7 @@ fn add_pattern_to_lookup_types(
|
|||
let region = loc_pattern.region;
|
||||
|
||||
match loc_pattern.value {
|
||||
Pattern::Identifier(_, symbol) => {
|
||||
Pattern::Identifier(symbol) => {
|
||||
let loc_type = Located {
|
||||
region,
|
||||
value: expr_type,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue