roc/test/snapshots/expr/if_expression.md
2025-10-16 07:00:23 -07:00

1 KiB

META

description=If expression with conditional
type=expr

SOURCE

if x > 5 "big" else "small"

EXPECTED

UNDEFINED VARIABLE - if_expression.md:1:4:1:5

PROBLEMS

UNDEFINED VARIABLE Nothing is named x in this scope. Is there an import or exposing missing up-top?

if_expression.md:1:4:1:5:

if x > 5 "big" else "small"

^

TOKENS

KwIf,LowerIdent,OpGreaterThan,Int,StringStart,StringPart,StringEnd,KwElse,StringStart,StringPart,StringEnd,
EndOfFile,

PARSE

(e-if-then-else
	(e-binop (op ">")
		(e-ident (raw "x"))
		(e-int (raw "5")))
	(e-string
		(e-string-part (raw "big")))
	(e-string
		(e-string-part (raw "small"))))

FORMATTED

NO CHANGE

CANONICALIZE

(e-if
	(if-branches
		(if-branch
			(e-binop (op "gt")
				(e-runtime-error (tag "ident_not_in_scope"))
				(e-num (value "5")))
			(e-string
				(e-literal (string "big")))))
	(if-else
		(e-string
			(e-literal (string "small")))))

TYPES

(expr (type "Str"))