fix: return optional result

cc @Kha
This commit is contained in:
Leonardo de Moura 2020-10-20 05:58:35 -07:00
parent e8cf086641
commit 702ceb7a3f
2 changed files with 9 additions and 1 deletions

View file

@ -85,7 +85,7 @@ def doFinally := parser! "finally " >> doSeq
@[builtinDoElemParser] def doBreak := parser! "break"
@[builtinDoElemParser] def doContinue := parser! "continue"
@[builtinDoElemParser] def doReturn := parser!:leadPrec "return " >> optional termParser
@[builtinDoElemParser] def doReturn := parser!:leadPrec withPosition ("return " >> optional (checkLineEq >> termParser))
@[builtinDoElemParser] def doDbgTrace := parser!:leadPrec "dbgTrace! " >> ((interpolatedStr termParser) <|> termParser)
@[builtinDoElemParser] def doAssert := parser!:leadPrec "assert! " >> termParser

View file

@ -0,0 +1,8 @@
#lang lean4
def f (x : Nat) : IO Unit := do
if x > 10 then
return
throw $ IO.userError "x ≤ 10"
#eval f 11