Skip to content

Commit

Permalink
add reproducer for invalid transfer error with invalid expected type
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent committed Jul 25, 2024
1 parent 211f6a5 commit af5f75d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions runtime/tests/interpreter/interpreter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11684,6 +11684,42 @@ func TestInterpretNilCoalesceReference(t *testing.T) {
)
}

func TestInterpretNilCoalesceAnyResourceAndPanic(t *testing.T) {

t.Parallel()

baseValueActivation := sema.NewVariableActivation(sema.BaseValueActivation)
baseValueActivation.DeclareValue(stdlib.PanicFunction)

baseActivation := activations.NewActivation(nil, interpreter.BaseActivation)
interpreter.Declare(baseActivation, stdlib.PanicFunction)

_, err := parseCheckAndInterpretWithOptions(t,
`
resource R {}
fun f(): @AnyResource? {
return <-create R()
}
let y <- f() ?? panic("no R")
`,
ParseCheckAndInterpretOptions{
CheckerConfig: &sema.Config{
BaseValueActivationHandler: func(_ common.Location) *sema.VariableActivation {
return baseValueActivation
},
},
Config: &interpreter.Config{
BaseActivationHandler: func(_ common.Location) *interpreter.VariableActivation {
return baseActivation
},
},
},
)
require.NoError(t, err)
}

func TestInterpretDictionaryDuplicateKey(t *testing.T) {

t.Parallel()
Expand Down

0 comments on commit af5f75d

Please sign in to comment.