Flow: Error when parsing colons in a comment

Created on 14 Jul 2019  路  3Comments  路  Source: facebook/flow

Flow version: 0.102

Expected behavior

No error or warning

Actual behavior

Throws a Unexpected token :Flow(ParseError)

When parsing
/* : */
or
/* ::: */

but not when there is two :
/* :: */

if other characters are present in the string (before the first colon) the error vanishes

bug needs triage

Most helpful comment

This should only apply when the file has the // @flow pragma. enabling Flow on a file changes the semantics of this, and one other construct -- a<b>(c) becomes a type argument, rather than ((a < b) > c). all our other syntax extensions are otherwise invalid JS, as far as I know.

So, this is working as intended (reopen if it's happening without @flow). If anything, we could probably use better documentation about the semantics changes vs normal JS.

All 3 comments

This is special syntax

This should only apply when the file has the // @flow pragma. enabling Flow on a file changes the semantics of this, and one other construct -- a<b>(c) becomes a type argument, rather than ((a < b) > c). all our other syntax extensions are otherwise invalid JS, as far as I know.

So, this is working as intended (reopen if it's happening without @flow). If anything, we could probably use better documentation about the semantics changes vs normal JS.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mjj2000 picture mjj2000  路  3Comments

ghost picture ghost  路  3Comments

bennoleslie picture bennoleslie  路  3Comments

ctrlplusb picture ctrlplusb  路  3Comments

pelotom picture pelotom  路  3Comments