feat: add array literal notation

This commit is contained in:
Leonardo de Moura 2019-12-19 11:42:39 -08:00
parent 76e75a1b53
commit eb24ec56dc
2 changed files with 9 additions and 0 deletions

View file

@ -723,6 +723,14 @@ fun stx expectedType? => do
let newStx := args.foldSepRevArgs (fun arg r => mkAppStx consId #[arg, r]) nilId;
elabTerm newStx expectedType?
@[builtinTermElab «arrayLit»] def elabArrayLit : TermElab :=
fun stx expectedType? => do
match_syntax stx.val with
| `(#[$args*]) => do
newStx ← `(List.toArray [$args*]);
withMacroExpansion stx.val (elabTerm newStx expectedType?)
| _ => throwError stx.val "unexpected array literal syntax"
def elabExplicitUniv (stx : Syntax) : TermElabM (List Level) :=
pure [] -- TODO

View file

@ -150,3 +150,4 @@ f a
#eval run "#check fun x => foo x x.w s4"
#eval run "#check bla (fun x => x.w) s4"
#eval run "#check #[1, 2, 3]"