markused: fix short program with selector option unwrapping only (fix #23109) (#23111)

This commit is contained in:
Felipe Pena 2024-12-09 13:14:44 -03:00 committed by GitHub
parent f7734165af
commit 49e1012baf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 0 deletions

View File

@ -1726,6 +1726,10 @@ fn (mut c Checker) selector_expr(mut node ast.SelectorExpr) ast.Type {
c.check_or_expr(node.or_block, unwrapped_typ, c.expected_or_type, node)
c.expected_or_type = ast.void_type
}
if c.pref.skip_unused && node.or_block.kind != .absent
&& !c.table.used_features.option_or_result {
c.table.used_features.option_or_result = true
}
return field.typ
}
if mut method := c.table.sym(c.unwrap_generic(typ)).find_method_with_generic_parent(field_name) {

View File

@ -0,0 +1 @@
2

View File

@ -0,0 +1 @@
2

View File

@ -0,0 +1,15 @@
module main
struct GameObject {
mut:
id int = 1
parent ?&GameObject
}
fn main() {
mut gameobject := GameObject{}
gameobject.parent = &GameObject{
id: 2
}
println('${gameobject.parent?.id}')
}