Quantcast
Channel: ReScript Forum - Latest posts
Viewing all articles
Browse latest Browse all 2592

Record in list decomposed in a single step needs type hint, is this a bug?

$
0
0

Hi tsnobip, thanks for your reply!

I did a minimal version to demonstrate the issue:

https://rescript-idea.github.io/try?code=LYewJgrgNgpgBAERgMwJYDtUBdUnXAXjgG8AoOOLATwAd4tCTyK4BDALjgGcsAnDAOYAaZhQBGnHv3TDmAX2awGAmFgBKMAMYheYRgAoAlIQB8JDnABEloXAlXLCikrgqsAGVQ8Dxgmf1uGtq6RrYALABMhqQKpC5gIACSDERGpkwUAPSZcNrANKiwXIqqcPoAHrZUvogoGNi46AB0bp48RiUMxKy2YnKM5aTM2bkg+YUwxc6l3b39REhomDh4LapBOmAdwzlivDCsANZTcC76s3ZyVTWL9SvNrV5YHVkAVMwAKgAW8PvBemgYFA9Kxcqx0AByBhieDIEAQdBgJpDFiJZBwbAQrhwMB1dAwPQYNjoEBYH68OCgSCwOA6OBoWC9aQCDEMDBYEDcbR0OxUdiiAC0cAACvs0OVBKy4AB3bBfbisVB6KnQeDoVjAGCcb4wACy4FVTVYgrgAHkKVw6JpUMgqJLsNjqHROC4yTAAGqsKAQLVwHX66kwJpuj60eBEbqcd0AQXcAFUAKJOV6ZGKkIA

module Definition = {
  type t = {
    a: string,
    b: string,
  }
  let getRecord = () => {a: "", b: ""}
  let getList = () => (getRecord(), 42)
}

let doIt = () => {
  // compiles
  let (x, y) = Definition.getList()
  let {a, b} = x

  // compiles
  let {a, b} = Definition.getRecord()

  // breaks
  let ({a, b}, y) = Definition.getList()
  /*
  The record field a can't be found.

   If it's defined in another module or file, bring it into scope by:
   - Prefixing it with said module name: TheModule.a
   - Or specifying its type: let theValue: TheModule.theType = {a: VALUE}
 */
}

Viewing all articles
Browse latest Browse all 2592

Trending Articles