diff --git a/lexer.go b/lexer.go
index <HASH>..<HASH> 100644
--- a/lexer.go
+++ b/lexer.go
@@ -298,7 +298,7 @@ func (self *_lexer) scanQuoteLiteral() _token {
 				if result != utf8.RuneError {
 					text.WriteRune(result)
 				} else {
-					text.WriteRune(value)
+					return errorIllegal()
 				}
 
 			case 'x':
@@ -306,7 +306,7 @@ func (self *_lexer) scanQuoteLiteral() _token {
 				if result != utf8.RuneError {
 					text.WriteRune(result)
 				} else {
-					text.WriteRune(value)
+					return errorIllegal()
 				}
 			default:
 				text.WriteRune(value)
diff --git a/lexer_test.go b/lexer_test.go
index <HASH>..<HASH> 100644
--- a/lexer_test.go
+++ b/lexer_test.go
@@ -271,4 +271,9 @@ Second line \
 	test("10e10000",
 		"number 10e10000",
 	)
+
+	test(`"\x0G"`,
+		"illegal",
+	)
+
 }
Recognize erroneous "\x..", "\u...." as errors

For example, "\x0G" is not valid