@@ -544,12 +544,18 @@ object StringContextMacro {
544
544
* @return reports an error if precision or width is specified for '%' or
545
545
* if precision is specified for end of line
546
546
*/
547
- def checkSpecials (partIndex : Int , conversionChar : Char , hasPrecision : Boolean , precision : Int , hasWidth : Boolean , width : Int ) = conversionChar match {
547
+ def checkSpecials (partIndex : Int , conversionChar : Char , hasPrecision : Boolean , precision : Int , hasWidth : Boolean , width : Int , flags : List [( Char , Int )] ) = conversionChar match {
548
548
case 'n' => {
549
549
checkNotAllowedParameter(hasPrecision, partIndex, precision, " precision" )
550
550
checkNotAllowedParameter(hasWidth, partIndex, width, " width" )
551
+ val notAllowedFlagOnCondition = for (flag <- List ('-' , '#' , '+' , ' ' , '0' , ',' , '(' )) yield (flag, true , " flags not allowed" )
552
+ checkUniqueFlags(partIndex, flags, notAllowedFlagOnCondition : _* )
553
+ }
554
+ case '%' => {
555
+ checkNotAllowedParameter(hasPrecision, partIndex, precision, " precision" )
556
+ val notAllowedFlagOnCondition = for (flag <- List ('#' , '+' , ' ' , '0' , ',' , '(' )) yield (flag, true , " Illegal flag '" + flag + " '" )
557
+ checkFlags(partIndex, flags, notAllowedFlagOnCondition : _* )
551
558
}
552
- case '%' => checkNotAllowedParameter(hasPrecision, partIndex, precision, " precision" )
553
559
case _ => // OK
554
560
}
555
561
@@ -588,7 +594,7 @@ object StringContextMacro {
588
594
case 'e' | 'E' | 'f' | 'g' | 'G' | 'a' | 'A' => checkFloatingPointConversion(partIndex, conversionChar, flags, hasPrecision, precision)
589
595
case 't' | 'T' => checkTimeConversion(partIndex, part, conversion, flags, hasPrecision, precision)
590
596
case 'b' | 'B' | 'h' | 'H' | 'S' | 's' => checkGeneralConversion(partIndex, argType, conversionChar, flags)
591
- case 'n' | '%' => checkSpecials(partIndex, conversionChar, hasPrecision, precision, hasWidth, width)
597
+ case 'n' | '%' => checkSpecials(partIndex, conversionChar, hasPrecision, precision, hasWidth, width, flags )
592
598
case illegal => reporter.partError(" illegal conversion character '" + illegal + " '" , partIndex, conversion)
593
599
}
594
600
0 commit comments