mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
add test
This commit is contained in:
parent
5265f0ff55
commit
69161ee9e6
1 changed files with 76 additions and 0 deletions
76
test/snapshots/issue/segfault_pr_8315.md
Normal file
76
test/snapshots/issue/segfault_pr_8315.md
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# META
|
||||
~~~ini
|
||||
description=Regression test for segfault caused by self-capturing closure (PR #8315)
|
||||
type=snippet
|
||||
~~~
|
||||
# SOURCE
|
||||
~~~roc
|
||||
# Minimal reproduction of segfault bug
|
||||
# A closure definition that captures itself causes infinite recursion
|
||||
# during closure construction in the interpreter
|
||||
|
||||
selfCapturing : {} -> U64
|
||||
selfCapturing = |{}| selfCapturing({})
|
||||
~~~
|
||||
# EXPECTED
|
||||
NIL
|
||||
# PROBLEMS
|
||||
NIL
|
||||
# TOKENS
|
||||
~~~zig
|
||||
LowerIdent,OpColon,OpenCurly,CloseCurly,OpArrow,UpperIdent,
|
||||
LowerIdent,OpAssign,OpBar,OpenCurly,CloseCurly,OpBar,LowerIdent,NoSpaceOpenRound,OpenCurly,CloseCurly,CloseRound,
|
||||
EndOfFile,
|
||||
~~~
|
||||
# PARSE
|
||||
~~~clojure
|
||||
(file
|
||||
(type-module)
|
||||
(statements
|
||||
(s-type-anno (name "selfCapturing")
|
||||
(ty-fn
|
||||
(ty-record)
|
||||
(ty (name "U64"))))
|
||||
(s-decl
|
||||
(p-ident (raw "selfCapturing"))
|
||||
(e-lambda
|
||||
(args
|
||||
(p-record))
|
||||
(e-apply
|
||||
(e-ident (raw "selfCapturing"))
|
||||
(e-record))))))
|
||||
~~~
|
||||
# FORMATTED
|
||||
~~~roc
|
||||
NO CHANGE
|
||||
~~~
|
||||
# CANONICALIZE
|
||||
~~~clojure
|
||||
(can-ir
|
||||
(d-let
|
||||
(p-assign (ident "selfCapturing"))
|
||||
(e-closure
|
||||
(captures
|
||||
(capture (ident "selfCapturing")))
|
||||
(e-lambda
|
||||
(args
|
||||
(p-record-destructure
|
||||
(destructs)))
|
||||
(e-call
|
||||
(e-lookup-local
|
||||
(p-assign (ident "selfCapturing")))
|
||||
(e-empty_record))))
|
||||
(annotation
|
||||
(declared-type
|
||||
(ty-fn (effectful false)
|
||||
(ty-record)
|
||||
(ty-lookup (name "U64") (builtin)))))))
|
||||
~~~
|
||||
# TYPES
|
||||
~~~clojure
|
||||
(inferred-types
|
||||
(defs
|
||||
(patt (type "{ } -> Num(Int(Unsigned64))")))
|
||||
(expressions
|
||||
(expr (type "{ } -> Num(Int(Unsigned64))"))))
|
||||
~~~
|
||||
Loading…
Add table
Add a link
Reference in a new issue