From 336e9eeb67622ebebb59a787cb7ede7c61c38c01 Mon Sep 17 00:00:00 2001 From: ascandone Date: Mon, 5 Aug 2024 16:46:26 +0200 Subject: [PATCH] fixed runtime err --- analysis/hover.go | 5 ++++- analysis/hover_test.go | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/analysis/hover.go b/analysis/hover.go index 7505d2d..d92574d 100644 --- a/analysis/hover.go +++ b/analysis/hover.go @@ -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) @@ -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: diff --git a/analysis/hover_test.go b/analysis/hover_test.go index 254b44a..994a61b 100644 --- a/analysis/hover_test.go +++ b/analysis/hover_test.go @@ -384,6 +384,17 @@ func TestHoverFaultTolerance(t *testing.T) { assert.Nil(t, hover) }) + t.Run("missing sent value", func(t *testing.T) { + input := ` + send ( + ) + ` + rng := RangeOfIndexed(input, "", 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] (