Repository: elm-tooling/elm-language-server (ts)

Issue:
type inference fails with empty record pattern
<!--- Provide a general summary of the issue in the Title above -->

## Expected Behavior

The following should typecheck ok:

```elm
f : { a : Int } -> Int
f {} =
    5
```

## Current Behavior

![image](https://user-images.githubusercontent.com/16308754/113461512-d5134a00-9414-11eb-834a-e80ee65702f2.png)


## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used: `elmtooling.elm-ls-vscode` `v2.1.0` 
* Editor used: vscode
* Environment name and version (e.g. node.js 5.4):
* Operating System and version: linux



Pull request description:
Fix type inference for empty record pattern
Fixes #571.

Patch:
diff --git a/src/compiler/typeInference.ts b/src/compiler/typeInference.ts
index 34823f9..8121474 100644
--- a/src/compiler/typeInference.ts
+++ b/src/compiler/typeInference.ts
@@ -1709,7 +1709,9 @@ export class InferenceScope {
   ): void {
     // Bind all patters to a InProgressBinding type
     // so we can use them before we know the type
-    const declaredNames = pattern.descendantsOfType("lower_pattern");
+    const declaredNames = pattern
+      .descendantsOfType("lower_pattern")
+      .filter((pattern) => pattern.text !== "");
     declaredNames.forEach((name) =>
       this.bindings.set(name, TInProgressBinding),
     );
diff --git a/src/compiler/utils/elmUtils.ts b/src/compiler/utils/elmUtils.ts
index 8e050e4..d1150b6 100644
--- a/src/compiler/utils/elmUtils.ts
+++ b/src/compiler/utils/elmUtils.ts
@@ -42,7 +42,7 @@ export function execCmdSync(
     });
   } catch (error) {
     connection.console.warn(JSON.stringify(error));
-    if (error.code && error.code === "ENOENT") {
+    if (error.errno && error.errno === "ENOENT") {
       connection.window.showErrorMessage(
         options.notFoundText
           ? options.notFoundText + ` I'm looking for '${cmd}' at '${cwd}'`
diff --git a/src/compiler/utils/expressionTree.ts b/src/compiler/utils/expressionTree.ts
index 4c3a23b..7da959c 100644
--- a/src/compiler/utils/expressionTree.ts
+++ b/src/compiler/utils/expressionTree.ts
@@ -664,7 +664,8 @@ export function mapSyntaxNodeToExpression(
           node,
         )
           ?.map(mapSyntaxNodeToExpression)
-          .filter(Utils.notUndefined) as ELowerPattern[];
+          .filter(Utils.notUndefined)
+          .filter((pattern) => pattern.text !== "") as ELowerPattern[];
         return recordPattern;
       }
 


Test patch:
diff --git a/test/diagnosticTests/elmDiagnostics.test.ts b/test/diagnosticTests/elmDiagnostics.test.ts
index 103a346..6bccf47 100644
--- a/test/diagnosticTests/elmDiagnostics.test.ts
+++ b/test/diagnosticTests/elmDiagnostics.test.ts
@@ -1479,6 +1479,18 @@ func result =
         Nothing ->
             ""
 
+  `;
+      await testTypeInference(basicsSources + source, [], true);
+    });
+
+    it("empty record pattern should not have an error", async () => {
+      const source = `
+--@ Test.elm
+module Test exposing (..)
+
+f : { a : Int } -> Int
+f {} =
+    5
   `;
       await testTypeInference(basicsSources + source, [], true);
     });