-
Notifications
You must be signed in to change notification settings - Fork 465
V11 & V12 - Fails to set value to nested optional mutable field #7406
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
Comments
Workaround is too add |
Here's an example that does not use mutable at all: type nested = {field?: int}
type pair = (nested, string)
let p: pair = ({}, "")
let x = fst(p)
let y = fst(p) Gives: let p = [
{},
""
];
let x = {};
let y = {}; So it seems that the initialisation |
Here's a tweaked example that does not use optional fields at all: type record = {field: int}
type pair = (record, string)
let p: pair = ({field:2}, "")
let x = fst(p)
let y = fst(p) and shows the duplication of the record value: let p = [
{
field: 2
},
""
];
let x = {
field: 2
};
let y = {
field: 2
}; |
cristianoc
added a commit
that referenced
this issue
May 5, 2025
…attening Fixes #7406 fix: avoid creating unnecessary copies of allocating constants in field flattening The field flattening optimization was creating unnecessary copies of allocating constants (like Const_block and Const_some), which could lead to memory issues. This change makes the optimization only flatten fields when the constant doesn't allocate memory.
cristianoc
added a commit
that referenced
this issue
May 5, 2025
…attening Fixes #7406 fix: avoid creating unnecessary copies of allocating constants in field flattening The field flattening optimization was creating unnecessary copies of allocating constants (like Const_block and Const_some), which could lead to memory issues. This change makes the optimization only flatten fields when the constant doesn't allocate memory.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://rescript-lang.org/try?version=v11.1.4&module=esmodule&code=C4TwDgpgBAdhDOwIBMoF4oG8C2BXYAhgEYA20AZgJYQnID8AXFJTMAL4BQokUA5gE4B7XGHRY4iFEwlJknDmWB8hIpgOGiMmGVKxt5iqORhjE-dAD4sHKMo0A6HcntUaqDGYC0FgJKsXQtgAysD8LLwcnEA
You can see how there's no field assignment in the code.
The text was updated successfully, but these errors were encountered: