Skip to content

Rescript erroneosly omits parentheses with float exponentiation #8549

Description

@wildfield

Thank you for filing! Check list:

  • Is it a bug? Usage questions should often be asked in the forum instead.
  • Concise, focused, friendly issue title & description.
  • A minimal, reproducible example.
  • OS and browser versions, if relevant.
  • Is it already fixed in master? Instructions

Reproduction ReScript 12.3.0 code:

let exponentTest = () => {
  2.0 ** (0.0 /. 10000.0)
}

Console.log(exponentTest())

Generated Javascript code:

function exponentTest() {
  return 2.0 ** 0.0 / 10000.0;
}

Actual output:

0.0001

Expected output:

1.0

The problem here is that 2.0 ** 0.0 / 10000.0 != 2.0 ** (0.0 / 10000.0). The former results in 0.001 while the latter results in 1.0.

I guess Javascript in this case has a different operation precedence.

Tested on Firefox 153.0.3 (64-bit), Arch Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions