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

1.2 KiB

META

description=Headerless file with main function
type=file

SOURCE

x = 5
main! = |_| x

EXPECTED

NIL

PROBLEMS

NIL

TOKENS

LowerIdent,OpAssign,Int,
LowerIdent,OpAssign,OpBar,Underscore,OpBar,LowerIdent,
EndOfFile,

PARSE

(file
	(type-module)
	(statements
		(s-decl
			(p-ident (raw "x"))
			(e-int (raw "5")))
		(s-decl
			(p-ident (raw "main!"))
			(e-lambda
				(args
					(p-underscore))
				(e-ident (raw "x"))))))

FORMATTED

NO CHANGE

CANONICALIZE

(can-ir
	(d-let
		(p-assign (ident "x"))
		(e-num (value "5")))
	(d-let
		(p-assign (ident "main!"))
		(e-closure
			(captures
				(capture (ident "x")))
			(e-lambda
				(args
					(p-underscore))
				(e-lookup-local
					(p-assign (ident "x")))))))

TYPES

(inferred-types
	(defs
		(patt (type "a where [a.from_numeral : Numeral -> Try(a, [InvalidNumeral(Str)])]"))
		(patt (type "_arg -> a where [a.from_numeral : Numeral -> Try(a, [InvalidNumeral(Str)])]")))
	(expressions
		(expr (type "a where [a.from_numeral : Numeral -> Try(a, [InvalidNumeral(Str)])]"))
		(expr (type "_arg -> a where [a.from_numeral : Numeral -> Try(a, [InvalidNumeral(Str)])]"))))