From f60f469c85b2bd925c98068b691d43b54d9d6e43 Mon Sep 17 00:00:00 2001 From: Ryo Nihei Date: Sun, 7 Mar 2021 23:44:09 +0900 Subject: Pass values in error type to panic() Because parser.parse() expects that recover() returns a value in error type, apply this change. --- compiler/parser.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'compiler/parser.go') diff --git a/compiler/parser.go b/compiler/parser.go index 53bd375..cdc4817 100644 --- a/compiler/parser.go +++ b/compiler/parser.go @@ -348,7 +348,7 @@ func genRangeAST(fromNode, toNode astNode) astNode { case 4: return gen4ByteCharRangeAST(from, to) } - panic(fmt.Sprintf("invalid range; from: %v, to: %v", from, to)) + panic(fmt.Errorf("invalid range; from: %v, to: %v", from, to)) } func genByteSeq(node astNode) []byte { @@ -360,7 +360,7 @@ func genByteSeq(node astNode) []byte { seq = append(seq, genByteSeq(n.right)...) return seq } - panic(fmt.Sprintf("genByteSeq() cannot handle %T: %v", node, node)) + panic(fmt.Errorf("genByteSeq() cannot handle %T: %v", node, node)) } func isValidOrder(from, to []byte) bool { -- cgit v1.2.3