Skip to content

Commit c2f49c4

Browse files
committed
Avoid accidentally printing floating point numbers as 10.f.
1 parent fd52df1 commit c2f49c4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/libsyntax/parse/token.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,13 @@ fn to_str(in: interner<@~str>, t: token) -> ~str {
165165
LIT_INT_UNSUFFIXED(i) {
166166
int::to_str(i as int, 10u)
167167
}
168-
LIT_FLOAT(s, t) { *in.get(s) + ast_util::float_ty_to_str(t) }
168+
LIT_FLOAT(s, t) {
169+
let mut body = *in.get(s);
170+
if body.ends_with(".") {
171+
body = body + "0"; // `10.f` is not a float literal
172+
}
173+
body + ast_util::float_ty_to_str(t)
174+
}
169175
LIT_STR(s) { ~"\"" + str::escape_default( *in.get(s)) + ~"\"" }
170176

171177
/* Name components */

0 commit comments

Comments
 (0)