From 3b215fd884d48736a2ca1165a316047208f05bb0 Mon Sep 17 00:00:00 2001 From: acofer Date: Thu, 13 May 2021 17:13:16 -0400 Subject: [PATCH] PLIN-3031: allow negative index for 0-indexed array alignment --- parse/index.go | 6 +++--- parse/index_test.go | 2 +- parse/tree.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/parse/index.go b/parse/index.go index 3f5b79c..d244a9e 100644 --- a/parse/index.go +++ b/parse/index.go @@ -5,7 +5,7 @@ import ( ) // Index Op will index the left and right nodes -func (o *Op) Index(start uint) Node { +func (o *Op) Index(start int) Node { var left Node var right Node @@ -26,9 +26,9 @@ func (o *Op) Index(start uint) Node { } // Index Leaf will add start to the current value -func (l *Leaf) Index(start uint) Node { +func (l *Leaf) Index(start int) Node { return &Leaf{ - Val: l.Val + start, + Val: uint(int(l.Val) + start), } } diff --git a/parse/index_test.go b/parse/index_test.go index 2f572e6..3357ef2 100644 --- a/parse/index_test.go +++ b/parse/index_test.go @@ -10,7 +10,7 @@ func TestIndex(t *testing.T) { cases := []struct { desc string fixture Node - start uint + start int expected Node }{ { diff --git a/parse/tree.go b/parse/tree.go index 7ba426f..a9f7bae 100644 --- a/parse/tree.go +++ b/parse/tree.go @@ -9,7 +9,7 @@ import ( type Node interface { Remove(uint) Node Eval(io.Writer) error - Index(uint) Node + Index(int) Node } // Leaf is a concrete Node that will hold a single value