Support for 'float' in type signatures.
This commit is contained in:
parent
865a2812b6
commit
0b63512f4c
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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); }
|
||||
|
@ -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](_,_),
|
||||
|
@ -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";}
|
||||
|
@ -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; }
|
||||
|
10
src/test/run-pass/float-signature.rs
Normal file
10
src/test/run-pass/float-signature.rs
Normal file
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user