@@ -83,14 +83,15 @@ fn (mut c Checker) string_inter_lit(mut node ast.StringInterLiteral) ast.Type {
83
83
if node.pluss[i] && ! typ.is_number () {
84
84
c.error ('plus prefix only allowed for numbers' , node.fmt_poss[i])
85
85
}
86
- if (typ.is_unsigned () && fmt ! in [`u` , `x` , `X` , `o` , `c` , `b` ])
86
+ if (( typ.is_unsigned () && fmt ! in [`u` , `x` , `X` , `o` , `c` , `b` ])
87
87
|| (typ.is_signed () && fmt ! in [`d` , `x` , `X` , `o` , `c` , `b` ])
88
88
|| (typ.is_int_literal ()
89
89
&& fmt ! in [`d` , `c` , `x` , `X` , `o` , `u` , `x` , `X` , `o` , `b` ])
90
90
|| (typ.is_float () && fmt ! in [`E` , `F` , `G` , `e` , `f` , `g` ])
91
91
|| (typ.is_pointer () && fmt ! in [`p` , `x` , `X` ])
92
92
|| (typ.is_string () && fmt ! in [`s` , `S` ])
93
- || (typ.idx () in [ast.i64_ type_idx, ast.f64_ type_idx] && fmt == `c` ) {
93
+ || (typ.idx () in [ast.i64_ type_idx, ast.f64_ type_idx] && fmt == `c` ))
94
+ && ! (typ.is_ptr () && fmt in [`p` , `x` , `X` ]) {
94
95
c.error ('illegal format specifier `${fmt:c} ` for type `${c.table.get_type_name(ftyp)} `' ,
95
96
node.fmt_poss[i])
96
97
}
0 commit comments