diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2021-03-07 23:44:09 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-03-07 23:44:09 +0900 |
commit | f60f469c85b2bd925c98068b691d43b54d9d6e43 (patch) | |
tree | fe6d6fec6cb3fd9aed278d7d945efbdfaae02aa4 | |
parent | Refactoring (diff) | |
download | tre-f60f469c85b2bd925c98068b691d43b54d9d6e43.tar.gz tre-f60f469c85b2bd925c98068b691d43b54d9d6e43.tar.xz |
Pass values in error type to panic()
Because parser.parse() expects that recover() returns a value in error type, apply this change.
-rw-r--r-- | compiler/parser.go | 4 |
1 files changed, 2 insertions, 2 deletions
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 { |