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