File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -480,18 +480,25 @@ extension Lexer.Cursor {
480480 /// - Returns: The parsed string without underscores
481481 mutating func parseUnderscoredChars( continueParsing: ( Unicode . Scalar ) -> Bool ) throws -> String {
482482 var value = String . UnicodeScalarView ( )
483- var lastChar : Unicode . Scalar ?
483+ var lastParsedChar : Unicode . Scalar ?
484484 while let char = try peek ( ) {
485- lastChar = char
486485 if char == " _ " {
486+ guard let lastChar = lastParsedChar else {
487+ throw createError ( " Invalid hex number, leading underscore " )
488+ }
489+ guard lastChar != " _ " else {
490+ throw createError ( " Invalid hex number, consecutive underscores " )
491+ }
492+ lastParsedChar = char
487493 _ = try next ( )
488494 continue
489495 }
490496 guard continueParsing ( char) else { break }
497+ lastParsedChar = char
491498 value. append ( char)
492499 _ = try next ( )
493500 }
494- if lastChar == " _ " {
501+ if lastParsedChar == " _ " {
495502 throw createError ( " Invalid hex number, trailing underscore " )
496503 }
497504 return String ( value)
Original file line number Diff line number Diff line change @@ -107,9 +107,7 @@ class EncoderTests: XCTestCase {
107107
108108 var stats = CompatibilityTestStats ( )
109109 let excluded : [ String ] = [
110- " float_literals.wast " ,
111110 " imports.wast " ,
112- " int_literals.wast " ,
113111 " start.wast " ,
114112 " token.wast " ,
115113 " utf8-invalid-encoding.wast "
You can’t perform that action at this time.
0 commit comments