mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
2 KiB
2 KiB
META
description=Match expression with wrong arrow
type=expr
SOURCE
match l {
[] -> Err(EmptyList)
[.., e] -> Ok(e)
}
EXPECTED
PARSE ERROR - wrong_arrow.md:2:8:2:8 PARSE ERROR - wrong_arrow.md:3:13:3:13 UNDEFINED VARIABLE - wrong_arrow.md:1:7:1:8
PROBLEMS
PARSE ERROR
Match branches use => instead of ->.
wrong_arrow.md:2:8:2:8:
[] -> Err(EmptyList)
^
PARSE ERROR
Match branches use => instead of ->.
wrong_arrow.md:3:13:3:13:
[.., e] -> Ok(e)
^
UNDEFINED VARIABLE
Nothing is named l in this scope.
Is there an import or exposing missing up-top?
wrong_arrow.md:1:7:1:8:
match l {
^
TOKENS
KwMatch,LowerIdent,OpenCurly,
OpenSquare,CloseSquare,OpArrow,UpperIdent,NoSpaceOpenRound,UpperIdent,CloseRound,
OpenSquare,DoubleDot,Comma,LowerIdent,CloseSquare,OpArrow,UpperIdent,NoSpaceOpenRound,LowerIdent,CloseRound,
CloseCurly,
EndOfFile,
PARSE
(e-match
(e-ident (raw "l"))
(branches
(branch
(p-list)
(e-apply
(e-tag (raw "Err"))
(e-tag (raw "EmptyList"))))
(branch
(p-list
(p-list-rest)
(p-ident (raw "e")))
(e-apply
(e-tag (raw "Ok"))
(e-ident (raw "e"))))))
FORMATTED
match l {
[] => Err(EmptyList)
[.., e] => Ok(e)
}
CANONICALIZE
(e-match
(match
(cond
(e-runtime-error (tag "ident_not_in_scope")))
(branches
(branch
(patterns
(pattern (degenerate false)
(p-list
(patterns))))
(value
(e-tag (name "Err")
(args
(e-tag (name "EmptyList"))))))
(branch
(patterns
(pattern (degenerate false)
(p-list
(patterns
(p-assign (ident "e")))
(rest-at (index 0)))))
(value
(e-tag (name "Ok")
(args
(e-lookup-local
(p-assign (ident "e"))))))))))
TYPES
(expr (type "[Err([EmptyList, .._others]), Ok(_a), .._others2]"))