Skip to content

"Undocumented" breaking change of array access in v11 #825

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
l2dy opened this issue Mar 9, 2024 · 3 comments
Closed

"Undocumented" breaking change of array access in v11 #825

l2dy opened this issue Mar 9, 2024 · 3 comments

Comments

@l2dy
Copy link
Contributor

l2dy commented Mar 9, 2024

The following code compiles in v10, but not in v11.

https://rescript-lang.org/try?version=v11.0.1&code=DYUwLgBAhhC8EG0AMAaCBGAugKFJA+nBAFIDOAdAJIB2Y5YA9gKIAeADg9SLQJZTAAKKMkwBKIA

let a = [0, 1]
let _ = Js.Int.toExponential(a[0])
[E] Line 2, column 29:

This has type: option<int>
  But this function argument is expecting: int

This change does not appear in https://rescript-lang.org/docs/manual/latest/migrate-to-v11#list-of-all-breaking-changes, but is discussed on the forum.

Ref #743

@fhammerschmidt
Copy link
Member

I admit this change is kinda hidden, since it's suggested to switch to the new standard library "ReScript Core" and open that by default. But the migration guide refers to the migration docs of ReScript Core which cover that, albeit briefly.

When you only use the playground, it totally looks like a hard breaking change since it automatically uses and opens ReScript Core for when v11 is selected. But the migration guide is actually not for the playground which also includes some other hacks to be able to run the compiler without a build system in the browser.

It's not in the list of breaking changes since those are only the ones from the compiler, they don't cover the switch from the old OCaml standard library (or ReScript's own Belt library) to ReScript Core. This will only actually be a breaking change when ReScript Core will be part of the compiler in v12.

@l2dy
Copy link
Contributor Author

l2dy commented Mar 10, 2024

I admit this change is kinda hidden, since it's suggested to switch to the new standard library "ReScript Core" and open that by default. But the migration guide refers to the migration docs of ReScript Core which cover that, albeit briefly.

When you only use the playground, it totally looks like a hard breaking change since it automatically uses and opens ReScript Core for when v11 is selected. But the migration guide is actually not for the playground which also includes some other hacks to be able to run the compiler without a build system in the browser.

I followed https://rescript-lang.org/docs/manual/latest/installation to initialize a project from scratch and migrated code over, but I understand that it's an unusual migration path.

Without going through the guide in depth, it looks more like a language change than what a library would do. Believing so, I only searched for keywords like array access and [ in the compiler part, but to no avail.

It's not in the list of breaking changes since those are only the ones from the compiler, they don't cover the switch from the old OCaml standard library (or ReScript's own Belt library) to ReScript Core. This will only actually be a breaking change when ReScript Core will be part of the compiler in v12.

It's technically correct to do so, but I think it won't hurt to list language changes as an example of breaking changes in the ReScript Core section.

@l2dy l2dy changed the title Undocument breaking change of array access in v11 "Undocumented" breaking change of array access in v11 Mar 10, 2024
@fhammerschmidt
Copy link
Member

The migration guide now mentions the array access changes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants