nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: gluon-lang/gluon
Pull request #311 (2017-07-07 05:47:55)

fix(completion): Complete type constructors which are implicitly impo…
…rted


Patch:
diff --git a/check/src/completion.rs b/check/src/completion.rs
index 82ac74ff..c30299a8 100644
--- a/check/src/completion.rs
+++ b/check/src/completion.rs
@@ -375,14 +375,20 @@ where
                 self.0.visit_expr(e);
             } else {
                 match e.value {
-                    Expr::TypeBindings(ref type_bindings, _) => {
+                    Expr::TypeBindings(ref type_bindings, ref e) => {
                         for type_binding in type_bindings {
                             self.0.on_found.on_alias(&type_binding.alias.value);
                         }
+                        self.0.visit_expr(e);
                     }
-                    _ => ()
+                    Expr::LetBindings(ref bindings, ref e) => {
+                        for binding in bindings {
+                            self.0.on_found.on_pattern(&binding.name);
+                        }
+                        self.0.visit_expr(e);
+                    }
+                    _ => walk_expr(self, e),
                 }
-                walk_expr(self, e);
             }
         }
     }


Test patch:
diff --git a/check/tests/completion.rs b/check/tests/completion.rs
index 504035cb..5d5d1359 100644
--- a/check/tests/completion.rs
+++ b/check/tests/completion.rs
@@ -458,6 +458,30 @@ match Abc 1 with
     assert_eq!(result, expected);
 }
 
+#[test]
+fn suggest_implicit_import_from_pattern() {
+    let _ = env_logger::init();
+
+    let text = r#"
+let { Test } =
+    type Test = | Abc Int
+    { Test }
+match Abc 1 with
+| 
+"#;
+    let env = MockEnv::new();
+
+    let (mut expr, _result) = support::typecheck_partial_expr(text);
+    expr.span.expansion_id = pos::UNKNOWN_EXPANSION;
+    let result: Vec<_> = completion::suggest(&env, &mut expr, 74.into())
+        .into_iter()
+        .map(|s| s.name)
+        .collect();
+
+    let expected = ["Abc".to_string()];
+    assert_eq!(result, expected);
+}
+
 #[test]
 fn metadata_at_variable() {
     let _ = env_logger::init();
Repository: gluon-lang/gluon
Pull request #646 (2018-10-17 12:30:44)

Fix Type::variant call for VmType derive
Fixes `Type::variant` still being referred to as `Type::variants` in the `VmType` derive, which is currently broken for enums because of it.


Patch:
diff --git a/codegen/src/vm_type.rs b/codegen/src/vm_type.rs
index d1188d1c..5e935c7a 100644
--- a/codegen/src/vm_type.rs
+++ b/codegen/src/vm_type.rs
@@ -119,7 +119,7 @@ fn gen_impl(container: &Container, ident: Ident, generics: Generics, data: &Data
                     }}
                 });
                 quote!{
-                    _gluon_base::types::Type::variants(
+                    _gluon_base::types::Type::variant(
                         vec![#(#variants),*]
                     )
                 }


Test patch:
diff --git a/codegen/tests/derive_vm_type.rs b/codegen/tests/derive_vm_type.rs
index 92f34311..5d09888e 100644
--- a/codegen/tests/derive_vm_type.rs
+++ b/codegen/tests/derive_vm_type.rs
@@ -25,6 +25,24 @@ fn struct_() {
     );
 }
 
+#[derive(VmType)]
+#[allow(unused)]
+enum Enum {
+    One,
+    Two(u32),
+    Three { id: String },
+}
+
+#[test]
+fn enum_() {
+    let vm = new_vm();
+
+    assert_eq!(
+        Enum::make_type(&vm).to_string(),
+        "| One\n| Two Int\n| Three String"
+    );
+}
+
 #[derive(VmType)]
 #[allow(unused)]
 struct Newtype(Struct);