diff --git a/jlexer/lexer.go b/jlexer/lexer.go index 169105a..d446fca 100644 --- a/jlexer/lexer.go +++ b/jlexer/lexer.go @@ -652,8 +652,6 @@ func (r *Lexer) number() string { } if !r.Ok() || r.token.kind != tokenNumber { if *UseSemanticErrors { - r.errSemantic() - r.SkipRecursive() return "" } r.errInvalidToken("number") diff --git a/tests/basic_test.go b/tests/basic_test.go index 34961ab..ea7fbbd 100644 --- a/tests/basic_test.go +++ b/tests/basic_test.go @@ -209,6 +209,9 @@ func TestNestedEasyJsonMarshal(t *testing.T) { } func TestSemanticErrors(t *testing.T) { + if !*jlexer.UseSemanticErrors { + return + } for i, test := range []struct { Data []byte ErrorNum int @@ -217,6 +220,18 @@ func TestSemanticErrors(t *testing.T) { Data: []byte(`[1, 2, 3, "4", "5"]`), ErrorNum: 2, }, + { + Data: []byte(`[1, {"2" : "3"}, 3, "4"`), + ErrorNum: 2, + }, + { + Data: []byte(`[1, "2", "3", "4", "5", "6"]`), + ErrorNum: 5, + }, + { + Data: []byte(`[1, 2, 3, 4, "5"]`), + ErrorNum: 1, + }, } { l := jlexer.Lexer{Data: test.Data}