diff --git a/Makefile.in b/Makefile.in index 14993f14f52..7c036fd6f7a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -528,7 +528,8 @@ docsnap: doc/rust.pdf # Float doesn't work in boot FLOAT_XFAILS := $(S)src/test/run-pass/float.rs \ - $(S)src/test/run-pass/float2.rs + $(S)src/test/run-pass/float2.rs \ + $(S)src/test/run-pass/float-signature.rs # Temporarily xfail tests broken by the nominal-tags change. diff --git a/src/Makefile b/src/Makefile index 66c87e9afd7..5079548f11a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -420,7 +420,8 @@ self: $(CFG_RUSTC) # Float doesn't work in boot FLOAT_XFAILS := test/run-pass/float.rs \ - test/run-pass/float2.rs + test/run-pass/float2.rs \ + test/run-pass/float-signature.rs # Temporarily xfail tests broken by the nominal-tags change. diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 9e13e706af4..063bc0e178f 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -349,6 +349,7 @@ impure fn parse_ty(parser p) -> @ast.ty { case (token.BOOL) { p.bump(); t = ast.ty_bool; } case (token.INT) { p.bump(); t = ast.ty_int; } case (token.UINT) { p.bump(); t = ast.ty_uint; } + case (token.FLOAT) { p.bump(); t = ast.ty_float; } case (token.STR) { p.bump(); t = ast.ty_str; } case (token.CHAR) { p.bump(); t = ast.ty_char; } case (token.MACH(?tm)) { p.bump(); t = ast.ty_machine(tm); } diff --git a/src/comp/middle/fold.rs b/src/comp/middle/fold.rs index 5daa7f1da72..a1b7761201b 100644 --- a/src/comp/middle/fold.rs +++ b/src/comp/middle/fold.rs @@ -1,5 +1,5 @@ import std.map.hashmap; -import std.option; + import std.option; import std.option.some; import std.option.none; @@ -44,6 +44,7 @@ type ast_fold[ENV] = (fn(&ENV e, &span sp) -> @ty) fold_ty_bool, (fn(&ENV e, &span sp) -> @ty) fold_ty_int, (fn(&ENV e, &span sp) -> @ty) fold_ty_uint, + (fn(&ENV e, &span sp) -> @ty) fold_ty_float, (fn(&ENV e, &span sp, ty_mach tm) -> @ty) fold_ty_machine, (fn(&ENV e, &span sp) -> @ty) fold_ty_char, (fn(&ENV e, &span sp) -> @ty) fold_ty_str, @@ -337,6 +338,7 @@ fn fold_ty[ENV](&ENV env, ast_fold[ENV] fld, @ty t) -> @ty { case (ast.ty_bool) { ret fld.fold_ty_bool(env_, t.span); } case (ast.ty_int) { ret fld.fold_ty_int(env_, t.span); } case (ast.ty_uint) { ret fld.fold_ty_uint(env_, t.span); } + case (ast.ty_float) { ret fld.fold_ty_float(env_, t.span); } case (ast.ty_machine(?m)) { ret fld.fold_ty_machine(env_, t.span, m); @@ -1064,6 +1066,10 @@ fn identity_fold_ty_uint[ENV](&ENV env, &span sp) -> @ty { ret @respan(sp, ast.ty_uint); } +fn identity_fold_ty_float[ENV](&ENV env, &span sp) -> @ty { + ret @respan(sp, ast.ty_float); +} + fn identity_fold_ty_machine[ENV](&ENV env, &span sp, ty_mach tm) -> @ty { ret @respan(sp, ast.ty_machine(tm)); @@ -1515,6 +1521,7 @@ fn new_identity_fold[ENV]() -> ast_fold[ENV] { fold_ty_bool = bind identity_fold_ty_bool[ENV](_,_), fold_ty_int = bind identity_fold_ty_int[ENV](_,_), fold_ty_uint = bind identity_fold_ty_uint[ENV](_,_), + fold_ty_float = bind identity_fold_ty_float[ENV](_,_), fold_ty_machine = bind identity_fold_ty_machine[ENV](_,_,_), fold_ty_char = bind identity_fold_ty_char[ENV](_,_), fold_ty_str = bind identity_fold_ty_str[ENV](_,_), diff --git a/src/comp/middle/metadata.rs b/src/comp/middle/metadata.rs index ce33658f44c..e384092ba5d 100644 --- a/src/comp/middle/metadata.rs +++ b/src/comp/middle/metadata.rs @@ -61,6 +61,7 @@ fn sty_str(ty.sty st, def_str ds) -> str { case (ty.ty_bool) {ret "b";} case (ty.ty_int) {ret "i";} case (ty.ty_uint) {ret "u";} + case (ty.ty_float) {ret "l";} case (ty.ty_machine(?mach)) { alt (mach) { case (common.ty_u8) {ret "Mb";} diff --git a/src/comp/middle/typeck.rs b/src/comp/middle/typeck.rs index 4175af6a99f..a52b39e2ac8 100644 --- a/src/comp/middle/typeck.rs +++ b/src/comp/middle/typeck.rs @@ -306,6 +306,7 @@ fn ast_ty_to_ty(ty_getter getter, &@ast.ty ast_ty) -> @ty.t { case (ast.ty_bool) { sty = ty.ty_bool; } case (ast.ty_int) { sty = ty.ty_int; } case (ast.ty_uint) { sty = ty.ty_uint; } + case (ast.ty_float) { sty = ty.ty_float; } case (ast.ty_machine(?tm)) { sty = ty.ty_machine(tm); } case (ast.ty_char) { sty = ty.ty_char; } case (ast.ty_str) { sty = ty.ty_str; } diff --git a/src/test/run-pass/float-signature.rs b/src/test/run-pass/float-signature.rs new file mode 100644 index 00000000000..da18390d69b --- /dev/null +++ b/src/test/run-pass/float-signature.rs @@ -0,0 +1,10 @@ +fn main() { + fn foo(float n) -> float { + ret n + 0.12345; + } + + let float n = 0.1; + let float m = foo(n); + + log m; +}