better documentation for underscore pattern

This commit is contained in:
Kiryl Dziamura 2024-07-05 13:09:11 +02:00
parent e0af069645
commit 64220567e5
No known key found for this signature in database
GPG Key ID: FB539501A4561ACF
2 changed files with 5 additions and 1 deletions

View File

@ -1677,6 +1677,10 @@ pub enum Pattern<'a> {
},
FloatLiteral(&'a str),
StrLiteral(StrLiteral<'a>),
/// Underscore pattern
/// Contains the name of underscore pattern (e.g. "a" is for "_a" in code)
/// Empty string is unnamed pattern ("" is for "_" in code)
Underscore(&'a str),
SingleQuote(&'a str),

View File

@ -76,7 +76,7 @@ pub fn jit_to_ast<'a, A: ReplApp<'a>>(
// Put in an underscore for each of the args, just to get the arity right.
for _ in 0..arguments.len() {
arg_patterns.push(Loc::at_zero(Pattern::Underscore("_")));
arg_patterns.push(Loc::at_zero(Pattern::Underscore("")));
}
let body_expr = Loc::at_zero(Expr::Record(Collection::empty()));