roc/test/snapshots/lambda_capture/no_capture.md
2025-11-23 01:22:01 -05:00

838 B

META

description="A pure lambda that takes an argument and does not capture from its environment."
type=expr

SOURCE

(|x| x + 1)(10)

EXPECTED

NIL

PROBLEMS

NIL

TOKENS

OpenRound,OpBar,LowerIdent,OpBar,LowerIdent,OpPlus,Int,CloseRound,NoSpaceOpenRound,Int,CloseRound,
EndOfFile,

PARSE

(e-apply
	(e-tuple
		(e-lambda
			(args
				(p-ident (raw "x")))
			(e-binop (op "+")
				(e-ident (raw "x"))
				(e-int (raw "1")))))
	(e-int (raw "10")))

FORMATTED

NO CHANGE

CANONICALIZE

(e-call
	(e-lambda
		(args
			(p-assign (ident "x")))
		(e-binop (op "add")
			(e-lookup-local
				(p-assign (ident "x")))
			(e-num (value "1"))))
	(e-num (value "10")))

TYPES

(expr (type "a where [a.from_numeral : Numeral -> Try(a, [InvalidNumeral(Str)])]"))