chore: ad-hoc match_syntax support in the new frontend

This commit is contained in:
Sebastian Ullrich 2020-01-07 14:21:49 -05:00 committed by Leonardo de Moura
parent db2218cbfd
commit c08fcdb662
2 changed files with 8 additions and 2 deletions

View file

@ -275,7 +275,7 @@ private partial def compileStxMatch (ref : Syntax) : List Syntax → List Alt
cond ← match info.argPats with
| some pats => `(Syntax.isOfKind discr $(quote kind) && Array.size (Syntax.getArgs discr) == $(quote pats.size))
| none => `(Syntax.isOfKind discr $(quote kind));
`(let discr := $discr; if $cond then $yes else $no)
`(let discr := $discr; if coe $cond then $yes else $no)
| _, _ => unreachable!
private partial def getPatternVarsAux : Syntax → TermElabM (List Syntax)

View file

@ -302,7 +302,13 @@ def elabLetPatDecl (ref : Syntax) (decl body : Syntax) (expectedType? : Option E
throwError decl "not implemented yet"
@[builtinTermElab «let»] def elabLet : TermElab :=
fun stx expectedType? => do
fun stx expectedType? => match_syntax stx with
| `(let $id:id := $decl; $body) => do
-- HACK: support single-id pattern let (as produced by quotations) by translation to ident let for now
let id := id.getArg 0;
stx ← `(let $id:ident := $decl; $body);
elabTerm stx expectedType?
| _ => do
-- `let` decl `;` body
let ref := stx;
let decl := stx.getArg 1;