Skip to content

Commit

Permalink
fixed runtime err
Browse files Browse the repository at this point in the history
  • Loading branch information
ascandone committed Aug 5, 2024
1 parent dfbba44 commit 336e9ee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion analysis/hover.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ func hoverOnVar(varDecl parser.VarDeclaration, position parser.Position) Hover {

func hoverOnSentValue(sentValue parser.SentValue, position parser.Position) Hover {
switch sentValue := sentValue.(type) {
case nil:
return nil

case *parser.SentValueAll:
return hoverOnLiteral(sentValue.Asset, position)

Expand Down Expand Up @@ -216,7 +219,7 @@ func hoverOnSource(source parser.Source, position parser.Position) Hover {

func hoverOnKeptOrDestination(inorderClause parser.KeptOrDestination, position parser.Position) Hover {
switch inorderClause := inorderClause.(type) {
case *parser.DestinationKept:
case nil, *parser.DestinationKept:
return nil

case *parser.DestinationTo:
Expand Down
11 changes: 11 additions & 0 deletions analysis/hover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,17 @@ func TestHoverFaultTolerance(t *testing.T) {
assert.Nil(t, hover)
})

t.Run("missing sent value", func(t *testing.T) {
input := `
send <invalidtk> (
)
`
rng := RangeOfIndexed(input, "<invalidtk>", 0)
program := parser.Parse(input).Value
hover := analysis.HoverOn(program, rng.Start)
assert.Nil(t, hover)
})

t.Run("missing inorder clause", func(t *testing.T) {
input := `
send [COIN 10] (
Expand Down

0 comments on commit 336e9ee

Please sign in to comment.