packages feed

typst 0.8.0.2 → 0.8.1

raw patch · 32 files changed

+827/−81 lines, 32 filesdep ~typst-symbols

Dependency ranges changed: typst-symbols

Files

CHANGELOG.md view
@@ -1,5 +1,24 @@ # Revision history for typst-hs +## 0.8.1++  * Fix parsing and evaluation of closures with _ (#84, Norbert Pozar).++  * Improve parsing of float literals (#83, Norbert Pozar).++  * Fix incorrect parsing of underscores in code (#82, Norbert Pozar).++  * Fix early return from function (#81).++  * Add default parameter for `first`, `last` methods on string, array+    (typst 0.14 addition).++  * Make the top-level document susceptible to set rules (#80).++  * Handle `#title` (#80).++  * Use typst-symbols 0.1.9 (typst 0.14 symbols).+ ## 0.8.0.2    * Give correct source positions even with nested includes (#74).
src/Typst/Evaluate.hs view
@@ -17,6 +17,7 @@ import Control.Monad (MonadPlus (mplus), foldM, foldM_) import Control.Monad.State (MonadTrans (lift)) import Data.List (intersperse, sortOn)+import Data.Foldable (toList) import qualified Data.Map as M import qualified Data.Map.Ordered as OM import Data.Maybe (isJust, fromMaybe)@@ -63,7 +64,12 @@   runParserT     (do contents <- mconcat <$> many pContent <* eof         -- "All documents are automatically wrapped in a document element."-        pure $ Elt "document" Nothing [("body", VContent contents)])+        els <- element (Identifier "document")+                   Arguments {positional = [VContent contents],+                              named = []}+        case toList els of+          [e] -> pure e+          _ -> fail "element returned something other than a singleton")     initialEvalState { evalOperations = operations,                        evalLocalDir = takeDirectory fp }     fp@@ -664,26 +670,6 @@       case maybeNegate v of         Nothing -> fail $ "Can't negate " <> show v         Just v' -> pure v'-    ToPower e1 e2 -> do-      e <- evalExpr e1-      b <- evalExpr e2-      case (b, e) of-        (VInteger i, VInteger j) ->-          pure $-            VInteger $-              floor ((fromIntegral i :: Double) ** (fromIntegral j :: Double))-        (VInteger i, VRatio j) ->-          pure $-            VFloat ((fromIntegral i :: Double) ** (fromRational j :: Double))-        (VRatio i, VInteger j) ->-          pure $-            VFloat (fromRational i ** (fromIntegral j :: Double))-        (VRatio i, VRatio j) -> pure $ VFloat (fromRational i ** fromRational j)-        (VFloat i, VInteger j) -> pure $ VFloat (i ** (fromIntegral j :: Double))-        (VFloat i, VFloat j) -> pure $ VFloat (i ** j)-        (VInteger i, VFloat j) -> pure $ VFloat ((fromIntegral i :: Double) ** j)-        (VFloat i, VRatio j) -> pure $ VFloat (i ** fromRational j)-        _ -> fail $ "Can't exponentiate " <> show b <> " to " <> show e     Plus e1 e2 -> do       v1 <- evalExpr e1       v2 <- evalExpr e2@@ -838,8 +824,9 @@       evalExpr e -- TODO for now we just ignore "context"     Return mbe -> do       -- these flow directives are examined in CodeBlock+      result <- maybe (pure VNone) evalExpr mbe       updateState (\st -> st {evalFlowDirective = FlowReturn (isJust mbe)})-      maybe (pure VNone) evalExpr mbe+      pure result     Continue -> do       updateState (\st -> st {evalFlowDirective = FlowContinue})       pure VNone@@ -875,6 +862,7 @@           (cs, _) <- loadModule t           pure $ VContent cs         _ -> fail "Include requires a path"+    Underscore -> fail "expected expression, found underscore"  toFunction ::   Monad m =>@@ -909,7 +897,10 @@                 (x : xs) -> do                   destructuringBind addIdentifier parts x                   pure $ as {positional = xs}-            setParam as SkipParam = pure as+            setParam as SkipParam = do+              case positional as of+                [] -> fail ("missing argument: pattern parameter")+                (_ : xs) -> pure $ as {positional = xs}         inBlock FunctionScope $ do           -- We create a closure around the identifiers defined           -- where the function is defined:
src/Typst/Methods.hs view
@@ -148,14 +148,14 @@           pure $ makeFunction $ pure $ VInteger (fromIntegral $ T.length t)         "rev" ->           pure $ makeFunction $ pure $ VString (T.reverse t)-        "first" ->+        "first" -> pure $ makeFunction $           if T.null t-            then fail "string is empty"-            else pure $ makeFunction $ pure $ VString $ T.take 1 t-        "last" ->+            then namedArg "default" Nothing >>= maybe (fail "empty string") pure+            else pure $ VString $ T.take 1 t+        "last" -> pure $ makeFunction $           if T.null t-            then fail "string is empty"-            else pure $ makeFunction $ pure $ VString $ T.takeEnd 1 t+            then namedArg "default" Nothing >>= maybe (fail "empty string") pure+            else pure $ VString $ T.takeEnd 1 t         "at" ->           pure $ makeFunction $ do             n <- toPos <$> nthArg 1@@ -391,13 +391,13 @@           pure $             makeFunction $               if V.null v-                then fail "empty array"+                then namedArg "default" Nothing >>= maybe (fail "empty array") pure                 else pure $ V.head v         "last" ->           pure $             makeFunction $               if V.null v-                then fail "empty array"+                then namedArg "default" Nothing >>= maybe (fail "empty array") pure                 else pure $ V.last v         "at" -> pure $ makeFunction $ do           pos <- toPos <$> nthArg 1
src/Typst/Module/Standard.hs view
@@ -235,7 +235,8 @@ meta =   [ makeElement Nothing "bibliography" [("source", One (TString :|: TArray :|: TBytes))],     makeElement Nothing "cite" [("key", One TLabel)],-    makeElement Nothing "document" [],+    makeElement Nothing "document" [("body", One TContent)],+    makeElement Nothing "title" [("body", One TContent)],     makeElementWithScope       Nothing       "figure"
src/Typst/Parse.hs view
@@ -767,12 +767,19 @@ isSpecial '(' = True -- so we don't gobble ( before URLs isSpecial _ = False -pIdentifier :: P Identifier-pIdentifier = lexeme $ try $ do+pIdentifierOrUnderscore :: P Identifier+pIdentifierOrUnderscore = lexeme $ try $ do   c <- satisfy isIdentStart   cs <- many $ satisfy isIdentContinue   pure $ Identifier $ T.pack (c : cs) +pIdentifier :: P Identifier+pIdentifier = do +  ident <- pIdentifierOrUnderscore+  if ident == "_"+    then fail "expected identifier, found underscore"+    else pure $ ident+ -- ident_start ::= unicode(XID_Start) -- ID_Start characters are derived from the Unicode General_Category of -- uppercase letters, lowercase letters, titlecase letters, modifier letters,@@ -817,23 +824,26 @@ --             "break", "continue", "return", "import", "include", "from"]  pExpr :: P Expr-pExpr = buildExpressionParser operatorTable pBasicExpr+pExpr = buildExpressionParser operatorTable (buildExpressionParser basicOperatorTable (pBaseExpr pIdentOrUnderscore))+--  -- A basic expression excludes the unary and binary operators outside of parens,--- but includes field access and function application. Needed for pHash.+-- but includes field access and function application. A single underscore is+-- not a valid identifier in a basic expression and should be interpreted as markup.+-- Needed for pHash. pBasicExpr :: P Expr-pBasicExpr = buildExpressionParser basicOperatorTable pBaseExpr+pBasicExpr = buildExpressionParser basicOperatorTable (pBaseExpr pIdent)  pQualifiedIdentifier :: P Expr pQualifiedIdentifier =   buildExpressionParser (replicate 4 [fieldAccess]) pIdent -pBaseExpr :: P Expr-pBaseExpr =+pBaseExpr :: P Expr -> P Expr+pBaseExpr ident_parser =   pLiteral     <|> pKeywordExpr     <|> pFuncExpr-    <|> pIdent+    <|> ident_parser     <|> pArrayExpr     <|> pDictExpr     <|> inParens pExpr@@ -879,8 +889,7 @@   take 12 (cycle [[fieldAccess], [functionCall]])     ++     -- precedence 7 (repeated because of parsec's quirks with postfix, prefix)-    replicate 6 [Postfix (ToPower <$> try (char 'e' *> notFollowedBy letter *> pExpr))]-    ++ replicate 6 [Prefix (Negated <$ op "-"), Prefix (id <$ op "+")]+    replicate 6 [Prefix (Negated <$ op "-"), Prefix (id <$ op "+")]     ++ [          -- precedence 6          [ Infix (Times <$ op "*") AssocLeft,@@ -949,25 +958,36 @@         _ -> fail $ "could not read " <> num <> " as octal digits"     _ -> do       as <- many1 digit <|> ("0" <$ lookAhead (try (char '.' *> digit)))-      pe <- option [] $ string "."+      pe <- +        option +          [] +          (try ( do+              void $ char '.'+              notFollowedBy (char '.' <|> satisfy isIdentStart)+              pure "."+          ))       bs <- many digit       es <-         option           ""           ( do-              void $ try $ char 'e' *> lookAhead (digit <|> char '-')-              minus <- option [] $ count 1 (char '-')+              void $ try $ oneOf "eE" *> lookAhead (digit <|> oneOf "+-")+              sign <- option [] $ count 1 (oneOf "+-")               ds <- many1 digit-              pure ("e" ++ minus ++ ds)+              pure ("e" ++ sign ++ ds)           )       let num = pref ++ as ++ pe ++ bs ++ es       case readMaybe num of         Just (i :: Integer) -> pure $ Left i         Nothing ->-          case readMaybe num of+          case readMaybe $ addTrailingZero num of             Just (d :: Double) -> pure $ Right d             Nothing -> fail $ "could not read " <> num <> " as integer" +addTrailingZero :: String -> String+addTrailingZero []  = [] +addTrailingZero num@(_:_) = if last num == '.' then num ++ "0" else num+ pNumeric :: P Literal pNumeric = lexeme $ do   result <- pNumber@@ -1001,6 +1021,13 @@ pIdent :: P Expr pIdent = Ident <$> pIdentifier +pIdentOrUnderscore :: P Expr+pIdentOrUnderscore = do+  ident <- pIdentifierOrUnderscore+  if ident == "_"+    then pure $ Underscore+    else pure $ Ident ident+ pBlock :: P Expr pBlock = Block <$> (pCodeBlock <|> pContent) @@ -1075,7 +1102,7 @@   where     pParamsOrIdent =       pParams-        <|> (do i <- pIdentifier+        <|> (do i <- pIdentifierOrUnderscore                 if i == "_"                    then pure [SkipParam]                    else pure [NormalParam i])@@ -1135,7 +1162,7 @@           )     pSkipParam = SkipParam <$ sym "_"     pNormalOrDefaultParam = do-      i <- pIdentifier+      i <- try pIdentifier       (DefaultParam i <$> (sym ":" *> pExpr)) <|> pure (NormalParam i)     pDestructuringParam = do       DestructuringBind parts <- pDestructuringBind@@ -1149,7 +1176,7 @@  pBindIdentifier :: P (Maybe Identifier) pBindIdentifier = do-  ident <- pIdentifier+  ident <- pIdentifierOrUnderscore   if ident == "_"      then pure Nothing      else pure $ Just ident
src/Typst/Syntax.hs view
@@ -118,7 +118,6 @@ data Expr   = Literal Literal   | Negated Expr-  | ToPower Expr Expr   | Times Expr Expr   | Divided Expr Expr   | Plus Expr Expr@@ -156,6 +155,7 @@   | Label Text   | Break   | Continue+  | Underscore   deriving (Show, Ord, Eq, Data, Typeable)  data Imports
+ test/typ/bugs/expr_underscore_00.out view
@@ -0,0 +1,73 @@+--- parse tree ---+[ Code+    "typ/bugs/expr_underscore_00.typ"+    ( line 1 , column 2 )+    (Let+       (BasicBind (Just (Identifier "test")))+       (FuncExpr+          [ NormalParam (Identifier "x") , NormalParam (Identifier "y") ]+          (Block+             (CodeBlock+                [ If+                    [ ( Equals (Ident (Identifier "x")) (Ident (Identifier "y"))+                      , Block (Content [ Text "\9989" ])+                      )+                    , ( Literal (Boolean True)+                      , Block+                          (Content+                             [ Text "\10060"+                             , Text "("+                             , Code+                                 "typ/bugs/expr_underscore_00.typ"+                                 ( line 1 , column 47 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "x")) ])+                             , Space+                             , Text "/"+                             , Text "="+                             , Space+                             , Code+                                 "typ/bugs/expr_underscore_00.typ"+                                 ( line 1 , column 59 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "y")) ])+                             , Text ")"+                             ])+                      )+                    ]+                ]))))+, SoftBreak+, Code+    "typ/bugs/expr_underscore_00.typ"+    ( line 2 , column 2 )+    (Let (BasicBind (Just (Identifier "m"))) (Literal (Int 1)))+, SoftBreak+, Emph+    [ Code+        "typ/bugs/expr_underscore_00.typ"+        ( line 3 , column 3 )+        (Ident (Identifier "m"))+    , Text "."+    ]+, SoftBreak+, Code+    "typ/bugs/expr_underscore_00.typ"+    ( line 4 , column 2 )+    (Ident (Identifier "m"))+, Text "."+, ParBreak+]+--- evaluated ---+document(body: { text(body: [+]), +                 text(body: [+]), +                 emph(body: { text(body: [1]), +                              text(body: [.]) }), +                 text(body: [+]), +                 text(body: [1]), +                 text(body: [.]), +                 parbreak() })
+ test/typ/bugs/expr_underscore_00.typ view
@@ -0,0 +1,3 @@+#let m=1+_#m._+#m.
+ test/typ/bugs/expr_underscore_01.out view
@@ -0,0 +1,49 @@+--- parse tree ---+[ Code+    "typ/bugs/expr_underscore_01.typ"+    ( line 1 , column 2 )+    (Let+       (BasicBind (Just (Identifier "test")))+       (FuncExpr+          [ NormalParam (Identifier "x") , NormalParam (Identifier "y") ]+          (Block+             (CodeBlock+                [ If+                    [ ( Equals (Ident (Identifier "x")) (Ident (Identifier "y"))+                      , Block (Content [ Text "\9989" ])+                      )+                    , ( Literal (Boolean True)+                      , Block+                          (Content+                             [ Text "\10060"+                             , Text "("+                             , Code+                                 "typ/bugs/expr_underscore_01.typ"+                                 ( line 1 , column 47 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "x")) ])+                             , Space+                             , Text "/"+                             , Text "="+                             , Space+                             , Code+                                 "typ/bugs/expr_underscore_01.typ"+                                 ( line 1 , column 59 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "y")) ])+                             , Text ")"+                             ])+                      )+                    ]+                ]))))+, SoftBreak+, Code+    "typ/bugs/expr_underscore_01.typ"+    ( line 2 , column 2 )+    (Block (CodeBlock [ Underscore ]))+, ParBreak+]+"typ/bugs/expr_underscore_01.typ" (line 2, column 2):+expected expression, found underscore
+ test/typ/bugs/expr_underscore_01.typ view
@@ -0,0 +1,3 @@+#{+  _+}
+ test/typ/bugs/expr_underscore_02.out view
@@ -0,0 +1,51 @@+--- parse tree ---+[ Code+    "typ/bugs/expr_underscore_02.typ"+    ( line 1 , column 2 )+    (Let+       (BasicBind (Just (Identifier "test")))+       (FuncExpr+          [ NormalParam (Identifier "x") , NormalParam (Identifier "y") ]+          (Block+             (CodeBlock+                [ If+                    [ ( Equals (Ident (Identifier "x")) (Ident (Identifier "y"))+                      , Block (Content [ Text "\9989" ])+                      )+                    , ( Literal (Boolean True)+                      , Block+                          (Content+                             [ Text "\10060"+                             , Text "("+                             , Code+                                 "typ/bugs/expr_underscore_02.typ"+                                 ( line 1 , column 47 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "x")) ])+                             , Space+                             , Text "/"+                             , Text "="+                             , Space+                             , Code+                                 "typ/bugs/expr_underscore_02.typ"+                                 ( line 1 , column 59 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "y")) ])+                             , Text ")"+                             ])+                      )+                    ]+                ]))))+, SoftBreak+, Code+    "typ/bugs/expr_underscore_02.typ"+    ( line 2 , column 2 )+    (Let+       (BasicBind (Just (Identifier "d")))+       (Dict [ Reg ( Underscore , Literal (Int 1) ) ]))+, ParBreak+]+"typ/bugs/expr_underscore_02.typ" (line 2, column 2):+expected expression, found underscore
+ test/typ/bugs/expr_underscore_02.typ view
@@ -0,0 +1,1 @@+#let d = (_: 1)
test/typ/bugs/math-realize-00.out view
@@ -170,7 +170,7 @@     , Code         "typ/bugs/math-realize-00.typ"         ( line 12 , column 12 )-        (Ident (Identifier "convolve"))+        (FieldAccess (Ident (Identifier "op")) (Ident (Identifier "ast")))     , Text "2"     ] , ParBreak
+ test/typ/compiler/closure-21.out view
@@ -0,0 +1,243 @@+--- parse tree ---+[ Code+    "typ/compiler/closure-21.typ"+    ( line 1 , column 2 )+    (Let+       (BasicBind (Just (Identifier "test")))+       (FuncExpr+          [ NormalParam (Identifier "x") , NormalParam (Identifier "y") ]+          (Block+             (CodeBlock+                [ If+                    [ ( Equals (Ident (Identifier "x")) (Ident (Identifier "y"))+                      , Block (Content [ Text "\9989" ])+                      )+                    , ( Literal (Boolean True)+                      , Block+                          (Content+                             [ Text "\10060"+                             , Text "("+                             , Code+                                 "typ/compiler/closure-21.typ"+                                 ( line 1 , column 47 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "x")) ])+                             , Space+                             , Text "/"+                             , Text "="+                             , Space+                             , Code+                                 "typ/compiler/closure-21.typ"+                                 ( line 1 , column 59 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "y")) ])+                             , Text ")"+                             ])+                      )+                    ]+                ]))))+, SoftBreak+, Code+    "typ/compiler/closure-21.typ"+    ( line 2 , column 2 )+    (FuncCall+       (Ident (Identifier "test"))+       [ NormalArg+           (FuncCall+              (FuncExpr [ SkipParam ] (Array []))+              [ NormalArg (Literal (Int 1)) ])+       , NormalArg (Array [])+       ])+, SoftBreak+, Code+    "typ/compiler/closure-21.typ"+    ( line 3 , column 2 )+    (FuncCall+       (Ident (Identifier "test"))+       [ NormalArg+           (FuncCall+              (FuncExpr [ SkipParam ] (Array []))+              [ NormalArg (Literal (Int 1)) ])+       , NormalArg (Array [])+       ])+, SoftBreak+, Code+    "typ/compiler/closure-21.typ"+    ( line 4 , column 2 )+    (FuncCall+       (Ident (Identifier "test"))+       [ NormalArg+           (FuncCall+              (FuncExpr+                 [ NormalParam (Identifier "x") , SkipParam ]+                 (Ident (Identifier "x")))+              [ NormalArg (Literal (Int 1)) , NormalArg (Literal (Int 2)) ])+       , NormalArg (Literal (Int 1))+       ])+, SoftBreak+, Code+    "typ/compiler/closure-21.typ"+    ( line 5 , column 2 )+    (FuncCall+       (Ident (Identifier "test"))+       [ NormalArg+           (FuncCall+              (FuncExpr+                 [ SkipParam , NormalParam (Identifier "x") ]+                 (Ident (Identifier "x")))+              [ NormalArg (Literal (Int 1)) , NormalArg (Literal (Int 2)) ])+       , NormalArg (Literal (Int 2))+       ])+, SoftBreak+, Code+    "typ/compiler/closure-21.typ"+    ( line 6 , column 2 )+    (FuncCall+       (Ident (Identifier "test"))+       [ NormalArg+           (FuncCall+              (FuncExpr+                 [ NormalParam (Identifier "x") , SkipParam , SkipParam ]+                 (Ident (Identifier "x")))+              [ NormalArg (Literal (Int 1))+              , NormalArg (Literal (Int 2))+              , NormalArg (Literal (Int 3))+              ])+       , NormalArg (Literal (Int 1))+       ])+, SoftBreak+, Code+    "typ/compiler/closure-21.typ"+    ( line 7 , column 2 )+    (FuncCall+       (Ident (Identifier "test"))+       [ NormalArg+           (FuncCall+              (FuncExpr+                 [ SkipParam , NormalParam (Identifier "x") , SkipParam ]+                 (Ident (Identifier "x")))+              [ NormalArg (Literal (Int 1))+              , NormalArg (Literal (Int 2))+              , NormalArg (Literal (Int 3))+              ])+       , NormalArg (Literal (Int 2))+       ])+, SoftBreak+, Code+    "typ/compiler/closure-21.typ"+    ( line 8 , column 2 )+    (FuncCall+       (Ident (Identifier "test"))+       [ NormalArg+           (FuncCall+              (FuncExpr+                 [ SkipParam , SkipParam , NormalParam (Identifier "x") ]+                 (Ident (Identifier "x")))+              [ NormalArg (Literal (Int 1))+              , NormalArg (Literal (Int 2))+              , NormalArg (Literal (Int 3))+              ])+       , NormalArg (Literal (Int 3))+       ])+, SoftBreak+, Code+    "typ/compiler/closure-21.typ"+    ( line 9 , column 2 )+    (FuncCall+       (Ident (Identifier "test"))+       [ NormalArg+           (FuncCall+              (FuncExpr+                 [ NormalParam (Identifier "x")+                 , NormalParam (Identifier "y")+                 , SkipParam+                 ]+                 (Array+                    [ Reg (Ident (Identifier "x")) , Reg (Ident (Identifier "y")) ]))+              [ NormalArg (Literal (Int 1))+              , NormalArg (Literal (Int 2))+              , NormalArg (Literal (Int 3))+              ])+       , NormalArg+           (Array [ Reg (Literal (Int 1)) , Reg (Literal (Int 2)) ])+       ])+, SoftBreak+, Code+    "typ/compiler/closure-21.typ"+    ( line 10 , column 2 )+    (FuncCall+       (Ident (Identifier "test"))+       [ NormalArg+           (FuncCall+              (FuncExpr+                 [ SkipParam+                 , NormalParam (Identifier "x")+                 , NormalParam (Identifier "y")+                 ]+                 (Array+                    [ Reg (Ident (Identifier "x")) , Reg (Ident (Identifier "y")) ]))+              [ NormalArg (Literal (Int 1))+              , NormalArg (Literal (Int 2))+              , NormalArg (Literal (Int 3))+              ])+       , NormalArg+           (Array [ Reg (Literal (Int 2)) , Reg (Literal (Int 3)) ])+       ])+, SoftBreak+, Code+    "typ/compiler/closure-21.typ"+    ( line 11 , column 2 )+    (FuncCall+       (Ident (Identifier "test"))+       [ NormalArg+           (FuncCall+              (FuncExpr+                 [ NormalParam (Identifier "x")+                 , SkipParam+                 , NormalParam (Identifier "y")+                 ]+                 (Array+                    [ Reg (Ident (Identifier "x")) , Reg (Ident (Identifier "y")) ]))+              [ NormalArg (Literal (Int 1))+              , NormalArg (Literal (Int 2))+              , NormalArg (Literal (Int 3))+              ])+       , NormalArg+           (Array [ Reg (Literal (Int 1)) , Reg (Literal (Int 3)) ])+       ])+, ParBreak+]+--- evaluated ---+document(body: { text(body: [+]), +                 text(body: [✅]), +                 text(body: [+]), +                 text(body: [✅]), +                 text(body: [+]), +                 text(body: [✅]), +                 text(body: [+]), +                 text(body: [✅]), +                 text(body: [+]), +                 text(body: [✅]), +                 text(body: [+]), +                 text(body: [✅]), +                 text(body: [+]), +                 text(body: [✅]), +                 text(body: [+]), +                 text(body: [✅]), +                 text(body: [+]), +                 text(body: [✅]), +                 text(body: [+]), +                 text(body: [✅]), +                 parbreak() })
+ test/typ/compiler/closure-21.typ view
@@ -0,0 +1,10 @@+#test((_ => ())(1), ())+#test(((_) => ())(1), ())+#test(((x, _) => x)(1, 2), 1)+#test(((_, x) => x)(1, 2), 2)+#test(((x, _, _) => x)(1, 2, 3), 1)+#test(((_, x, _) => x)(1, 2, 3), 2)+#test(((_, _, x) => x)(1, 2, 3), 3)+#test(((x, y, _) => (x, y))(1, 2, 3), (1, 2))+#test(((_, x, y) => (x, y))(1, 2, 3), (2, 3))+#test(((x, _, y) => (x, y))(1, 2, 3), (1, 3))
+ test/typ/compiler/closure-22.out view
@@ -0,0 +1,52 @@+--- parse tree ---+[ Code+    "typ/compiler/closure-22.typ"+    ( line 1 , column 2 )+    (Let+       (BasicBind (Just (Identifier "test")))+       (FuncExpr+          [ NormalParam (Identifier "x") , NormalParam (Identifier "y") ]+          (Block+             (CodeBlock+                [ If+                    [ ( Equals (Ident (Identifier "x")) (Ident (Identifier "y"))+                      , Block (Content [ Text "\9989" ])+                      )+                    , ( Literal (Boolean True)+                      , Block+                          (Content+                             [ Text "\10060"+                             , Text "("+                             , Code+                                 "typ/compiler/closure-22.typ"+                                 ( line 1 , column 47 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "x")) ])+                             , Space+                             , Text "/"+                             , Text "="+                             , Space+                             , Code+                                 "typ/compiler/closure-22.typ"+                                 ( line 1 , column 59 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "y")) ])+                             , Text ")"+                             ])+                      )+                    ]+                ]))))+, SoftBreak+, Comment+, Code+    "typ/compiler/closure-22.typ"+    ( line 3 , column 2 )+    (FuncCall+       (FuncExpr [ SkipParam , SkipParam ] (Array []))+       [ NormalArg (Literal (Int 1)) ])+, ParBreak+]+"typ/compiler/closure-22.typ" (line 3, column 2):+missing argument: pattern parameter
+ test/typ/compiler/closure-22.typ view
@@ -0,0 +1,2 @@+// missing argument: pattern parameter +#((_, _) => ())(1)
+ test/typ/compiler/float-literal-00.out view
@@ -0,0 +1,78 @@+--- parse tree ---+[ Code+    "typ/compiler/float-literal-00.typ"+    ( line 1 , column 2 )+    (Let+       (BasicBind (Just (Identifier "test")))+       (FuncExpr+          [ NormalParam (Identifier "x") , NormalParam (Identifier "y") ]+          (Block+             (CodeBlock+                [ If+                    [ ( Equals (Ident (Identifier "x")) (Ident (Identifier "y"))+                      , Block (Content [ Text "\9989" ])+                      )+                    , ( Literal (Boolean True)+                      , Block+                          (Content+                             [ Text "\10060"+                             , Text "("+                             , Code+                                 "typ/compiler/float-literal-00.typ"+                                 ( line 1 , column 47 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "x")) ])+                             , Space+                             , Text "/"+                             , Text "="+                             , Space+                             , Code+                                 "typ/compiler/float-literal-00.typ"+                                 ( line 1 , column 59 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "y")) ])+                             , Text ")"+                             ])+                      )+                    ]+                ]))))+, SoftBreak+, Code+    "typ/compiler/float-literal-00.typ"+    ( line 2 , column 2 )+    (FuncCall+       (Ident (Identifier "test"))+       [ NormalArg+           (Array+              [ Reg (Literal (Float 1.0))+              , Reg (Literal (Float 0.1))+              , Reg (Literal (Float 0.1))+              , Reg (Literal (Float 10.0))+              , Reg (Literal (Float 0.1))+              , Reg (Literal (Float 10.0))+              , Reg (Literal (Float 10.0))+              , Reg (Literal (Float 10.0))+              , Reg (Literal (Float 0.1))+              ])+       , NormalArg+           (Array+              [ Reg (Literal (Float 1.0))+              , Reg (Literal (Float 0.1))+              , Reg (Literal (Float 0.1))+              , Reg (Literal (Float 10.0))+              , Reg (Literal (Float 0.1))+              , Reg (Literal (Float 10.0))+              , Reg (Literal (Float 10.0))+              , Reg (Literal (Float 10.0))+              , Reg (Literal (Float 0.1))+              ])+       ])+, ParBreak+]+--- evaluated ---+document(body: { text(body: [+]), +                 text(body: [✅]), +                 parbreak() })
+ test/typ/compiler/float-literal-00.typ view
@@ -0,0 +1,1 @@+#test((1., .1, 1e-1, 1e+1, 1.0e-1, 1.0e+1, 1E1, 1.0E+1, 1E-1), (1.0, 0.1, 0.1, 10.0, 0.1, 10.0, 10.0, 10.0, 0.1))
+ test/typ/compiler/float-literal-01.out view
@@ -0,0 +1,50 @@+--- parse tree ---+[ Code+    "typ/compiler/float-literal-01.typ"+    ( line 1 , column 2 )+    (Let+       (BasicBind (Just (Identifier "test")))+       (FuncExpr+          [ NormalParam (Identifier "x") , NormalParam (Identifier "y") ]+          (Block+             (CodeBlock+                [ If+                    [ ( Equals (Ident (Identifier "x")) (Ident (Identifier "y"))+                      , Block (Content [ Text "\9989" ])+                      )+                    , ( Literal (Boolean True)+                      , Block+                          (Content+                             [ Text "\10060"+                             , Text "("+                             , Code+                                 "typ/compiler/float-literal-01.typ"+                                 ( line 1 , column 47 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "x")) ])+                             , Space+                             , Text "/"+                             , Text "="+                             , Space+                             , Code+                                 "typ/compiler/float-literal-01.typ"+                                 ( line 1 , column 59 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "y")) ])+                             , Text ")"+                             ])+                      )+                    ]+                ]))))+, SoftBreak+, Comment+, Code+    "typ/compiler/float-literal-01.typ"+    ( line 3 , column 2 )+    (FieldAccess (Ident (Identifier "e")) (Literal (Int 1)))+, ParBreak+]+"typ/compiler/float-literal-01.typ" (line 3, column 2):+Integer does not have a method "e" or FieldAccess requires a dictionary
+ test/typ/compiler/float-literal-01.typ view
@@ -0,0 +1,2 @@+// Should parse as field access on integer+#1.e
test/typ/compiler/ops-03.out view
@@ -65,9 +65,7 @@     (FuncCall        (Ident (Identifier "test"))        [ NormalArg-           (ToPower-              (Minus (Literal (Int 2)) (Literal (Float 1.0e-2)))-              (Literal (Int 1)))+           (Minus (Literal (Float 100.0)) (Literal (Float 1.0e-2)))        , NormalArg (Literal (Float 99.99))        ]) , ParBreak@@ -431,11 +429,7 @@                  text(body: [✅]),                   text(body: [ ]), -                 text(body: [❌(]), -                 text(body: [1.0]), -                 text(body: [ /= ]), -                 text(body: [99.99]), -                 text(body: [)]), +                 text(body: [✅]),                   parbreak(),                   text(body: [✅]),                   parbreak(), 
test/typ/math/delimited-02.out view
@@ -48,7 +48,7 @@         (FieldAccess            (Ident (Identifier "l"))            (FieldAccess-              (Ident (Identifier "double")) (Ident (Identifier "bracket"))))+              (Ident (Identifier "stroked")) (Ident (Identifier "bracket"))))     , MFrac (Text "a") (Text "b")     , Code         "typ/math/delimited-02.typ"@@ -56,7 +56,7 @@         (FieldAccess            (Ident (Identifier "r"))            (FieldAccess-              (Ident (Identifier "double")) (Ident (Identifier "bracket"))))+              (Ident (Identifier "stroked")) (Ident (Identifier "bracket"))))     , Code         "typ/math/delimited-02.typ"         ( line 3 , column 11 )@@ -73,7 +73,7 @@                    (FieldAccess                       (Ident (Identifier "r"))                       (FieldAccess-                         (Ident (Identifier "double")) (Ident (Identifier "bracket"))))+                         (Ident (Identifier "stroked")) (Ident (Identifier "bracket"))))                , MFrac (Text "a") (Text "b")                , Code                    "typ/math/delimited-02.typ"@@ -81,7 +81,7 @@                    (FieldAccess                       (Ident (Identifier "r"))                       (FieldAccess-                         (Ident (Identifier "double")) (Ident (Identifier "bracket"))))+                         (Ident (Identifier "stroked")) (Ident (Identifier "bracket"))))                ]            ])     , Code
test/typ/math/frac-06.out view
@@ -67,7 +67,7 @@         (FieldAccess            (Ident (Identifier "l"))            (FieldAccess-              (Ident (Identifier "double")) (Ident (Identifier "bracket"))))+              (Ident (Identifier "stroked")) (Ident (Identifier "bracket"))))     , Text "x"     , MFrac         (Code@@ -76,7 +76,7 @@            (FieldAccess               (Ident (Identifier "r"))               (FieldAccess-                 (Ident (Identifier "double")) (Ident (Identifier "bracket")))))+                 (Ident (Identifier "stroked")) (Ident (Identifier "bracket")))))         (Text "2")     , HardBreak     , MFrac (Text "1.2") (Text "3.7")
test/typ/math/root-03.out view
@@ -54,7 +54,7 @@                    (FieldAccess                       (Ident (Identifier "l"))                       (FieldAccess-                         (Ident (Identifier "double")) (Ident (Identifier "bracket"))))+                         (Ident (Identifier "stroked")) (Ident (Identifier "bracket"))))                , Text "x"                , MAttach                    Nothing@@ -65,7 +65,7 @@                       (FieldAccess                          (Ident (Identifier "r"))                          (FieldAccess-                            (Ident (Identifier "double")) (Ident (Identifier "bracket")))))+                            (Ident (Identifier "stroked")) (Ident (Identifier "bracket")))))                , Text "+"                , Code                    "typ/math/root-03.typ"@@ -73,7 +73,7 @@                    (FieldAccess                       (Ident (Identifier "l"))                       (FieldAccess-                         (Ident (Identifier "double")) (Ident (Identifier "bracket"))))+                         (Ident (Identifier "stroked")) (Ident (Identifier "bracket"))))                , Text "y"                , MAttach                    Nothing@@ -84,7 +84,7 @@                       (FieldAccess                          (Ident (Identifier "r"))                          (FieldAccess-                            (Ident (Identifier "double")) (Ident (Identifier "bracket")))))+                            (Ident (Identifier "stroked")) (Ident (Identifier "bracket")))))                ]            ])     , Text "<"@@ -94,7 +94,7 @@         (FieldAccess            (Ident (Identifier "l"))            (FieldAccess-              (Ident (Identifier "double")) (Ident (Identifier "bracket"))))+              (Ident (Identifier "stroked")) (Ident (Identifier "bracket"))))     , Text "z"     , Code         "typ/math/root-03.typ"@@ -102,7 +102,7 @@         (FieldAccess            (Ident (Identifier "r"))            (FieldAccess-              (Ident (Identifier "double")) (Ident (Identifier "bracket"))))+              (Ident (Identifier "stroked")) (Ident (Identifier "bracket"))))     ] , SoftBreak , Equation
test/typ/math/spacing-00.out view
@@ -133,7 +133,7 @@     , Code         "typ/math/spacing-00.typ"         ( line 9 , column 8 )-        (Ident (Identifier "convolve"))+        (FieldAccess (Ident (Identifier "op")) (Ident (Identifier "ast")))     , Text "b"     ] , Space
test/typ/math/syntax-01.out view
@@ -70,7 +70,10 @@     , Code         "typ/math/syntax-01.typ"         ( line 4 , column 5 )-        (Ident (Identifier "mapsto"))+        (FieldAccess+           (Ident (Identifier "r"))+           (FieldAccess+              (Ident (Identifier "bar")) (Ident (Identifier "arrow"))))     , Code         "typ/math/syntax-01.typ"         ( line 4 , column 9 )@@ -83,7 +86,7 @@                    (FieldAccess                       (Ident (Identifier "l"))                       (FieldAccess-                         (Ident (Identifier "double")) (Ident (Identifier "bracket"))))+                         (Ident (Identifier "stroked")) (Ident (Identifier "bracket"))))                , Text "1"                , Code                    "typ/math/syntax-01.typ"@@ -91,7 +94,7 @@                    (FieldAccess                       (Ident (Identifier "r"))                       (FieldAccess-                         (Ident (Identifier "double")) (Ident (Identifier "bracket"))))+                         (Ident (Identifier "stroked")) (Ident (Identifier "bracket"))))                , MAlignPoint                , Text "if "                , Text "n"@@ -107,7 +110,7 @@                , Code                    "typ/math/syntax-01.typ"                    ( line 6 , column 7 )-                   (Ident (Identifier "convolve"))+                   (FieldAccess (Ident (Identifier "op")) (Ident (Identifier "ast")))                , Text "3"                , MAlignPoint                , Text "if "
test/typ/meta/document-00.out view
@@ -59,4 +59,5 @@ ]),                   text(body: [ What’s up?]), -                 parbreak() })+                 parbreak() }, +         title: "Hello")
test/typ/meta/document-01.out view
@@ -53,6 +53,7 @@ , ParBreak ] --- evaluated ----document(body: { text(body: [+document(author: ("A", "B"), +         body: { text(body: [ ]),                   parbreak() })
+ test/typ/regression/issue81.out view
@@ -0,0 +1,84 @@+--- parse tree ---+[ Code+    "typ/regression/issue81.typ"+    ( line 1 , column 2 )+    (Let+       (BasicBind (Just (Identifier "test")))+       (FuncExpr+          [ NormalParam (Identifier "x") , NormalParam (Identifier "y") ]+          (Block+             (CodeBlock+                [ If+                    [ ( Equals (Ident (Identifier "x")) (Ident (Identifier "y"))+                      , Block (Content [ Text "\9989" ])+                      )+                    , ( Literal (Boolean True)+                      , Block+                          (Content+                             [ Text "\10060"+                             , Text "("+                             , Code+                                 "typ/regression/issue81.typ"+                                 ( line 1 , column 47 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "x")) ])+                             , Space+                             , Text "/"+                             , Text "="+                             , Space+                             , Code+                                 "typ/regression/issue81.typ"+                                 ( line 1 , column 59 )+                                 (FuncCall+                                    (Ident (Identifier "repr"))+                                    [ NormalArg (Ident (Identifier "y")) ])+                             , Text ")"+                             ])+                      )+                    ]+                ]))))+, SoftBreak+, Code+    "typ/regression/issue81.typ"+    ( line 2 , column 2 )+    (LetFunc+       (Identifier "bug")+       []+       (Block+          (CodeBlock+             [ If+                 [ ( Literal (Boolean True)+                   , Block+                       (CodeBlock+                          [ Return+                              (Just+                                 (FuncCall+                                    (Ident (Identifier "heading"))+                                    [ NormalArg (Block (Content [ Text "1" ]))+                                    , KeyValArg (Identifier "level") (Literal (Int 2))+                                    ]))+                          ])+                   )+                 ]+             , Return+                 (Just+                    (FuncCall+                       (Ident (Identifier "strong"))+                       [ NormalArg (Block (Content [ Text "3" ])) ]))+             ])))+, SoftBreak+, Code+    "typ/regression/issue81.typ"+    ( line 8 , column 2 )+    (FuncCall (Ident (Identifier "bug")) [])+, ParBreak+]+--- evaluated ---+document(body: { text(body: [+]), +                 text(body: [+]), +                 heading(body: text(body: [1]), +                         level: 2), +                 parbreak() })
+ test/typ/regression/issue81.typ view
@@ -0,0 +1,7 @@+#let bug() = {+  if true {+    return heading([1], level: 2)+  }+  return strong([3])+}+#bug()
typst.cabal view
@@ -1,6 +1,6 @@ cabal-version:      2.4 name:               typst-version:            0.8.0.2+version:            0.8.1 synopsis:           Parsing and evaluating typst syntax. description:        A library for parsing and evaluating typst syntax.                     Typst (<https://typst.app>) is a document layout and@@ -62,7 +62,7 @@      -- other-extensions:     build-depends:    base >= 4.14 && <= 5,-                      typst-symbols >= 0.1.8.1 && < 0.1.9,+                      typst-symbols >= 0.1.9 && < 0.1.10,                       mtl,                       vector,                       parsec,