You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For expressions such as @some_field.nested_field, where nested_field is typed as T, if the surrounding method is fn mut, the return type is T instead of mut T. However, if the surrounding method is just fn the return type is (as expected) ref T. Thus, it seems that for fn mut we're no longer applying the correct ownership to nested fields.
Please list the exact steps necessary to reproduce the bug
Run this:
class Lexer[T] {
let @input: T
}
class Parser[T] {
let @lexer: Lexer[T]
fn mut example {
@lexer.input.TEST
}
}
class async Main {
fn async main {}
}
This produces:
/var/home/yorickpeterse/homes/arch/Downloads/test.inko:9:5 error(invalid-symbol): the method 'TEST' isn't defined for type 'T'
What it instead should produce is:
/var/home/yorickpeterse/homes/arch/Downloads/test.inko:9:5 error(invalid-symbol): the method 'TEST' isn't defined for type 'mut T'
Because of the lack of T: mut, we then return the type as-is.
This poses a new question: inside an fn mut, what should the type of a type parameter T be if it doesn't specify the mut requirement? If we return mut T we may allow mutations, which may be unsound (e.g. if T is a ref Something at runtime). If we return a ref T instead this could potentially be confusing, but at least it would be sound.
This is also related to #618, and specifically my thoughts in #618 (comment).
Please describe the bug
For expressions such as
@some_field.nested_field
, wherenested_field
is typed asT
, if the surrounding method isfn mut
, the return type isT
instead ofmut T
. However, if the surrounding method is justfn
the return type is (as expected)ref T
. Thus, it seems that forfn mut
we're no longer applying the correct ownership to nested fields.Please list the exact steps necessary to reproduce the bug
Run this:
This produces:
What it instead should produce is:
Operating system
Arch Linux
Inko version
0.13.1
Rust version
1.73.0
Related issues
The text was updated successfully, but these errors were encountered: