Fix comments and remove commented-out code.
This commit is contained in:
parent
da8d3fc1fc
commit
5bea2d163d
|
@ -795,14 +795,20 @@ pub enum Pattern<Constructor, Type> {
|
|||
},
|
||||
|
||||
/// The creation of a variable.
|
||||
/// e.g. `assert [this_is_a_var, .._] = x`
|
||||
/// e.g. `expect [this_is_a_var, .._] = x`
|
||||
/// e.g. `let foo = 42`
|
||||
Var {
|
||||
location: Span,
|
||||
name: String,
|
||||
},
|
||||
|
||||
/// A name given to a sub-pattern using the `as` keyword.
|
||||
/// e.g. `assert (1, [_, _] as the_list) = x`
|
||||
///
|
||||
/// ```aiken
|
||||
/// when foo is {
|
||||
/// [_, _] as the_list -> ...
|
||||
/// }
|
||||
/// ```
|
||||
Assign {
|
||||
name: String,
|
||||
location: Span,
|
||||
|
@ -849,7 +855,6 @@ impl<A, B> Pattern<A, B> {
|
|||
| Pattern::List { location, .. }
|
||||
| Pattern::Discard { location, .. }
|
||||
| Pattern::Tuple { location, .. }
|
||||
// | Pattern::Concatenate { location, .. }
|
||||
| Pattern::Constructor { location, .. } => *location,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ You can use '{discard}' and numbers to distinguish between similar names.
|
|||
#[error("I found a discarded expression not bound to a variable.\n")]
|
||||
#[diagnostic(code("implicit_discard"))]
|
||||
#[diagnostic(help(
|
||||
"A function can contain a sequence of expressions. However, any expression but the last one must be assign to a variable using the {keyword_let} keyword. If you really wish to discard an expression that is unused, you can assign it to '{discard}'.",
|
||||
"A function can contain a sequence of expressions. However, any expression but the last one must be assigned to a variable using the {keyword_let} keyword. If you really wish to discard an expression that is unused, you can assign it to '{discard}'.",
|
||||
keyword_let = "let".if_supports_color(Stdout, |s| s.yellow()),
|
||||
discard = "_".if_supports_color(Stdout, |s| s.yellow())
|
||||
))]
|
||||
|
|
|
@ -151,73 +151,6 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
|
|||
Ok(typed_multi)
|
||||
}
|
||||
|
||||
// fn infer_pattern_bit_string(
|
||||
// &mut self,
|
||||
// mut segments: Vec<UntypedPatternBitStringSegment>,
|
||||
// location: Span,
|
||||
// ) -> Result<TypedPattern, Error> {
|
||||
// let last_segment = segments.pop();
|
||||
|
||||
// let mut typed_segments: Vec<_> = segments
|
||||
// .into_iter()
|
||||
// .map(|s| self.infer_pattern_segment(s, false))
|
||||
// .try_collect()?;
|
||||
|
||||
// if let Some(s) = last_segment {
|
||||
// let typed_last_segment = self.infer_pattern_segment(s, true)?;
|
||||
// typed_segments.push(typed_last_segment)
|
||||
// }
|
||||
|
||||
// Ok(TypedPattern::BitString {
|
||||
// location,
|
||||
// segments: typed_segments,
|
||||
// })
|
||||
// }
|
||||
|
||||
// fn infer_pattern_segment(
|
||||
// &mut self,
|
||||
// segment: UntypedPatternBitStringSegment,
|
||||
// is_last_segment: bool,
|
||||
// ) -> Result<TypedPatternBitStringSegment, Error> {
|
||||
// let UntypedPatternBitStringSegment {
|
||||
// location,
|
||||
// options,
|
||||
// value,
|
||||
// ..
|
||||
// } = segment;
|
||||
|
||||
// let options: Vec<_> = options
|
||||
// .into_iter()
|
||||
// .map(|o| infer_bit_string_segment_option(o, |value, typ| self.unify(value, typ)))
|
||||
// .try_collect()?;
|
||||
|
||||
// let segment_type = bit_string::type_options_for_pattern(&options, !is_last_segment)
|
||||
// .map_err(|error| Error::BitStringSegmentError {
|
||||
// error: error.error,
|
||||
// location: error.location,
|
||||
// })?;
|
||||
|
||||
// let typ = {
|
||||
// match value.deref() {
|
||||
// Pattern::Var { .. } if segment_type == string() => {
|
||||
// Err(Error::BitStringSegmentError {
|
||||
// error: bit_string::ErrorType::VariableUtfSegmentInPattern,
|
||||
// location,
|
||||
// })
|
||||
// }
|
||||
// _ => Ok(segment_type),
|
||||
// }
|
||||
// }?;
|
||||
// let typed_value = self.unify(*value, typ.clone())?;
|
||||
|
||||
// Ok(BitStringSegment {
|
||||
// location,
|
||||
// value: Box::new(typed_value),
|
||||
// options,
|
||||
// type_: typ,
|
||||
// })
|
||||
// }
|
||||
|
||||
/// When we have an assignment or a case expression we unify the pattern with the
|
||||
/// inferred type of the subject in order to determine what variables to insert
|
||||
/// into the environment (or to detect a type error).
|
||||
|
@ -236,29 +169,6 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
|
|||
Ok(Pattern::Var { name, location })
|
||||
}
|
||||
|
||||
// Pattern::Concatenate {
|
||||
// location,
|
||||
// left_location,
|
||||
// right_location,
|
||||
// left_side_string,
|
||||
// right_side_assignment,
|
||||
// } => {
|
||||
// // The entire concatenate pattern must be a string
|
||||
// self.environment.unify(tipo, string(), location)?;
|
||||
|
||||
// // The right hand side may assign a variable, which is the suffix of the string
|
||||
// if let AssignName::Variable(right) = &right_side_assignment {
|
||||
// self.insert_variable(right.as_ref(), string(), right_location, location)?;
|
||||
// };
|
||||
|
||||
// Ok(Pattern::Concatenate {
|
||||
// location,
|
||||
// left_location,
|
||||
// right_location,
|
||||
// left_side_string,
|
||||
// right_side_assignment,
|
||||
// })
|
||||
// }
|
||||
Pattern::Assign {
|
||||
name,
|
||||
pattern,
|
||||
|
|
Loading…
Reference in New Issue