mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ast, checker: make SelectorExpr.root_ident return ?Ident (#9647)
This commit is contained in:
parent
b346dd9464
commit
50f59674ce
@ -149,14 +149,18 @@ pub mut:
|
||||
}
|
||||
|
||||
// root_ident returns the origin ident where the selector started.
|
||||
pub fn (e &SelectorExpr) root_ident() Ident {
|
||||
pub fn (e &SelectorExpr) root_ident() ?Ident {
|
||||
mut root := e.expr
|
||||
for root is SelectorExpr {
|
||||
// TODO: remove this line
|
||||
selector_expr := root as SelectorExpr
|
||||
root = selector_expr.expr
|
||||
}
|
||||
return root as Ident
|
||||
if root is Ident {
|
||||
return root as Ident
|
||||
}
|
||||
|
||||
return none
|
||||
}
|
||||
|
||||
// module declaration
|
||||
|
@ -5116,9 +5116,10 @@ fn (c Checker) smartcast(expr ast.Expr, cur_type ast.Type, to_type_ ast.Type, mu
|
||||
mut orig_type := 0
|
||||
if field := c.table.find_field(expr_sym, expr.field_name) {
|
||||
if field.is_mut {
|
||||
root_ident := expr.root_ident()
|
||||
if v := scope.find_var(root_ident.name) {
|
||||
is_mut = v.is_mut
|
||||
if root_ident := expr.root_ident() {
|
||||
if v := scope.find_var(root_ident.name) {
|
||||
is_mut = v.is_mut
|
||||
}
|
||||
}
|
||||
}
|
||||
if orig_type == 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user