Skip to content

async function with @this attribute #6100

Closed
@Mepy

Description

@Mepy
// ReScript
let add = x=>async(y)=> x+y
let method = @this this=> async arg=>await this->add(arg)

In rescript v10.1.3, the example above will fail as the following :

FAILED: 
  We've found a bug for you!

  1 │ // ReScript
  2 │ let add = x=>async(y)=> x+y
  3 │ let method = @this this=> async arg=>await this->add(arg) 
  4 │ 

  Await on expression not in an async context

By the way, the following ReScript code will generate JavaScript code without async:

// ReScript
let method = @this this=> async arg=>this+arg
// JavaScript
function method(arg) {
  var $$this = this ;
  return $$this + arg | 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions