lukehoban / atom-ide-flow

Atom IDE support for Flow
MIT License
87 stars 17 forks source link

ide-flow sometimes indicates wrong line #46

Open dchambers opened 8 years ago

dchambers commented 8 years ago

flow-ide sometimes seems to indicate the long line of code even though Flow has told it where the error is. For example, if I have a code snippet like this:

/* @flow */
type Type = {p1: boolean};
const f = (obj: Type) => obj; // error gets shown here
f({p1: true});
f({p2: true}); // invalid code here

Then Flow will give me an easy to comprehend error message like this:

src/index.js:5
  5: f({p2: true}); // invalid code here
     ^^^^^^^^^^^^^ function call
  3: const f = (obj: Type) => obj; // error gets shown here
                     ^^^^ property `p1`. Property not found in
  5: f({p2: true}); // invalid code here
       ^^^^^^^^^^ object literal

whereas flow-ide will indicate line 3 only, and display the error message property 'p1'. Property not found in.

This should work since even the JSON output from Flow seems to provide the correct information here:

{
  "passed":false,
  "errors":[{
    "operation":{
      "descr":"function call",
      "path":"/home/dominicc/dev/btczero/src/shared/types/index.js",
      "line":5,
      "endline":5,
      "start":1,
      "end":13
    },
    "message":[
      {
        "descr":"property `p1`",
        "level":"error",
        "path":"/home/dominicc/dev/btczero/src/shared/types/index.js",
        "line":3,
        "endline":3,
        "start":17,
        "end":20
      },
      {
        "descr":"Property not found in",
        "level":"error",
        "path":"",
        "line":0,
        "endline":0,
        "start":1,
        "end":0
      },
      {
        "descr":"object literal",
        "level":"error",
        "path":"/home/dominicc/dev/btczero/src/shared/types/index.js",
        "line":5,
        "endline":5,
        "start":3,
        "end":12
      }
    ],
    "kind":"infer"
  }],
  "version":"59d090c1390486bcf585e65f2cfe0214ee74f773 Dec 18 2015 21:50:15"
}