From 1212e59beed25d768bfaf7bb202aa955a87106e9 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 10 Jan 2019 22:49:43 +0100 Subject: Fix assertion error in unification (hopefully) Currently, all types that we handle during inference need to be resolved as far as possible at the time. It's maybe too brittle of an invariant; I need to think how we can do this better. This should fix #484 though, I hope (if it's the same case as I managed to reproduce). --- crates/ra_hir/src/ty/tests.rs | 12 ++++++++++++ crates/ra_hir/src/ty/tests/data/bug_484.txt | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 crates/ra_hir/src/ty/tests/data/bug_484.txt (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index d8c0af326..815aecda7 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs @@ -230,6 +230,18 @@ fn test2(a1: *const A, a2: *mut A) { ); } +#[test] +fn infer_bug_484() { + check_inference( + r#" +fn test() { + let x = if true {}; +} +"#, + "bug_484.txt", + ); +} + fn infer(content: &str) -> String { let (db, _, file_id) = MockDatabase::with_single_file(content); let source_file = db.source_file(file_id); diff --git a/crates/ra_hir/src/ty/tests/data/bug_484.txt b/crates/ra_hir/src/ty/tests/data/bug_484.txt new file mode 100644 index 000000000..300530551 --- /dev/null +++ b/crates/ra_hir/src/ty/tests/data/bug_484.txt @@ -0,0 +1,5 @@ +[11; 37) '{ l... {}; }': () +[20; 21) 'x': () +[24; 34) 'if true {}': () +[27; 31) 'true': bool +[32; 34) '{}': () -- cgit v1.2.3