diff options
author | Marcus Klaas de Vries <[email protected]> | 2019-01-10 17:08:54 +0000 |
---|---|---|
committer | Marcus Klaas de Vries <[email protected]> | 2019-01-14 12:54:31 +0000 |
commit | 1574715be5d3fc7e07160708810dcbc9c1b01733 (patch) | |
tree | c482c99282393d75606c4487d316103b14208561 /crates/ra_hir/src/expr.rs | |
parent | 5f5dc20d85dead5fbd51d163451f796255c9faea (diff) |
Use type variables to determine exact type for ambiguous numeric literals
Diffstat (limited to 'crates/ra_hir/src/expr.rs')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index bc8515836..2798937a6 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -699,7 +699,22 @@ impl ExprCollector { | |||
699 | // TODO: actually parse integer | 699 | // TODO: actually parse integer |
700 | Literal::Int(0u64, ty) | 700 | Literal::Int(0u64, ty) |
701 | } | 701 | } |
702 | SyntaxKind::FLOAT_NUMBER => Literal::Float(0, UncertainFloatTy::Unknown), | 702 | SyntaxKind::FLOAT_NUMBER => { |
703 | let text = c.text().to_string(); | ||
704 | |||
705 | // FIXME: don't do it like this. maybe use something like | ||
706 | // the IntTy::from_name functions | ||
707 | let ty = if text.ends_with("f64") { | ||
708 | UncertainFloatTy::Known(FloatTy::F64) | ||
709 | } else if text.ends_with("f32") { | ||
710 | UncertainFloatTy::Known(FloatTy::F32) | ||
711 | } else { | ||
712 | UncertainFloatTy::Unknown | ||
713 | }; | ||
714 | |||
715 | // TODO: actually parse value | ||
716 | Literal::Float(0, ty) | ||
717 | } | ||
703 | SyntaxKind::STRING => { | 718 | SyntaxKind::STRING => { |
704 | // FIXME: this likely includes the " characters | 719 | // FIXME: this likely includes the " characters |
705 | let text = c.text().to_string(); | 720 | let text = c.text().to_string(); |