From cb1dff1baf0fcd14f287263ee005bef4ed53e030 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sat, 7 Nov 2020 00:09:45 +0100 Subject: [PATCH] cleanup --- compiler/gen/src/layout_id.rs | 3 +-- compiler/gen/src/llvm/build.rs | 1 - compiler/mono/src/ir.rs | 5 ++++- compiler/types/src/solved_types.rs | 6 ++++++ examples/effect/Main.roc | 1 - 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/compiler/gen/src/layout_id.rs b/compiler/gen/src/layout_id.rs index 55d3c0db41..263f011087 100644 --- a/compiler/gen/src/layout_id.rs +++ b/compiler/gen/src/layout_id.rs @@ -14,13 +14,12 @@ impl LayoutId { } } -#[derive(Debug)] struct IdsByLayout<'a> { by_id: MutMap, u32>, next_id: u32, } -#[derive(Default, Debug)] +#[derive(Default)] pub struct LayoutIds<'a> { by_symbol: MutMap>, } diff --git a/compiler/gen/src/llvm/build.rs b/compiler/gen/src/llvm/build.rs index 461d2aa8d1..3dca02a6da 100644 --- a/compiler/gen/src/llvm/build.rs +++ b/compiler/gen/src/llvm/build.rs @@ -3441,7 +3441,6 @@ fn get_foreign_symbol<'a, 'ctx, 'env>( function_type: FunctionType<'ctx>, ) -> FunctionValue<'ctx> { let module = env.module; - let context = env.context; match module.get_function(foreign_symbol.as_str()) { Some(gvalue) => gvalue, diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index 28abf97dbf..bc6cb9ab4a 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -1344,12 +1344,14 @@ pub fn specialize_all<'a>( mut procs: Procs<'a>, layout_cache: &mut LayoutCache<'a>, ) -> Procs<'a> { - dbg!(&procs.externals_others_need); let it = procs.externals_others_need.specs.clone(); let it = it .into_iter() .map(|(symbol, solved_types)| { + // for some unclear reason, the MutSet does not deduplicate according to the hash + // instance. So we do it manually here let mut as_vec: std::vec::Vec<_> = solved_types.into_iter().collect(); + use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; @@ -1365,6 +1367,7 @@ pub fn specialize_all<'a>( as_vec.into_iter().map(move |s| (symbol, s)) }) .flatten(); + for (name, solved_type) in it.into_iter() { let partial_proc = match procs.partial_procs.get(&name) { Some(v) => v.clone(), diff --git a/compiler/types/src/solved_types.rs b/compiler/types/src/solved_types.rs index a031c95ecd..ba52a9ee43 100644 --- a/compiler/types/src/solved_types.rs +++ b/compiler/types/src/solved_types.rs @@ -26,6 +26,12 @@ impl Solved { } } +/// A custom hash instance, that treats flex vars specially, so that +/// +/// `Foo 100 200 100` hashes to the same as `Foo 300 100 300` +/// +/// i.e., we can rename the flex variables, so long as it happens consistently. +/// this is important so we don't generate the same PartialProc twice. impl Hash for SolvedType { fn hash(&self, state: &mut H) { hash_solved_type_help(self, &mut Vec::new(), state); diff --git a/examples/effect/Main.roc b/examples/effect/Main.roc index 767c135fbf..23ee7e2c2e 100644 --- a/examples/effect/Main.roc +++ b/examples/effect/Main.roc @@ -2,7 +2,6 @@ app Main provides [ main ] imports [ Effect ] main : Effect.Effect {} as Fx main = - Effect.putLine "Hello" |> Effect.after \{} -> Effect.putChar 87 # |> Effect.after \{} -> Effect.putLine "orld"