Purescript: Parse error thrown for the `**` operator in foreign files.

Created on 29 Nov 2017  路  3Comments  路  Source: purescript/purescript

This for example:

"use strict"

function powerOfTwo (power) {
  return 2.0 ** power;
};

exports.powerOfTwo = powerOfTwo
module Power where

foreign import powerOfTwo :: Number -> Number

Throws this error

    The module could not be parsed:


    MulToken {tokenSpan = TokenPn 58 4 15, tokenComment = []}

Most helpful comment

PureScript only supports ECMAScript 5 (which was standardized in 2009).

The ** operator was added in ECMAScript 2016, which is quite recent.

You can use Math.pow(2.0, power) instead.

All 3 comments

PureScript only supports ECMAScript 5 (which was standardized in 2009).

The ** operator was added in ECMAScript 2016, which is quite recent.

You can use Math.pow(2.0, power) instead.

This would need to be addressed in language-javascript, but @Pauan is right that this is expected behavior as we expect ES5 syntax.

TIL ** was introduced in ECMAScript 2016. Thanks 馃檪!

Was this page helpful?
0 / 5 - 0 ratings