mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
Merge pull request #1591 from rtfeldman/single-quote-literal
Single Quote literal
This commit is contained in:
commit
d3acf34415
26 changed files with 404 additions and 18 deletions
|
@ -2040,8 +2040,11 @@ fn pattern_to_when<'a>(
|
|||
}
|
||||
|
||||
UnwrappedOpaque { .. } => todo_opaques!(),
|
||||
|
||||
IntLiteral(..) | NumLiteral(..) | FloatLiteral(..) | StrLiteral(_) => {
|
||||
IntLiteral(..)
|
||||
| NumLiteral(..)
|
||||
| FloatLiteral(..)
|
||||
| StrLiteral(..)
|
||||
| roc_can::pattern::Pattern::SingleQuote(..) => {
|
||||
// These patters are refutable, and thus should never occur outside a `when` expression
|
||||
// They should have been replaced with `UnsupportedPattern` during canonicalization
|
||||
unreachable!("refutable pattern {:?} where irrefutable pattern is expected. This should never happen!", pattern.value)
|
||||
|
@ -3147,6 +3150,13 @@ pub fn with_hole<'a>(
|
|||
hole,
|
||||
),
|
||||
|
||||
SingleQuote(character) => Stmt::Let(
|
||||
assigned,
|
||||
Expr::Literal(Literal::Int(character as _)),
|
||||
Layout::int_width(IntWidth::I32),
|
||||
hole,
|
||||
),
|
||||
|
||||
Num(var, num_str, num, _bound) => {
|
||||
// first figure out what kind of number this is
|
||||
match num_argument_to_int_or_float(env.subs, env.target_info, var, false) {
|
||||
|
@ -7746,6 +7756,7 @@ fn from_can_pattern_help<'a>(
|
|||
}
|
||||
}
|
||||
StrLiteral(v) => Ok(Pattern::StrLiteral(v.clone())),
|
||||
SingleQuote(c) => Ok(Pattern::IntLiteral(*c as _, IntWidth::I32)),
|
||||
Shadowed(region, ident, _new_symbol) => Err(RuntimeError::Shadowing {
|
||||
original_region: *region,
|
||||
shadow: ident.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue