Skip to content

Incorrect type for await result when using PPX #7261

Closed
@cknitt

Description

@cknitt

On current master, await is broken when using a PPX.

The following code compiles fine without PPX:

let test = async () => false

let f = async () =>
  if await test() {
    Console.log("OK")
  }

but fails with PPX (rescript-schema-ppx) with the following error:

  We've found a bug for you!
  /Users/christoph/projects/cca/repro/src/Test.res:4:6-17

  2 │
  3 │ let f = async () =>
  4 │   if await test() {
  5 │     Console.log("OK")
  6 │   }

  This has type: promise<bool>
  But if conditions must always be of type: bool

  To fix this, change the highlighted code so it evaluates to a bool.

The issue is not present yet in

eaf8e7b Fix issue with pattern matching empty list which interferes with boolean optimisations.

but is present in

c2ad39e AST: Remove Pexp_new

Metadata

Metadata

Assignees

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