checker: dont re match/cast with position() when already cast to sum type
parent
7e4e3abc2c
commit
8df7637853
|
@ -470,7 +470,7 @@ pub fn (mut c Checker) infix_expr(infix_expr mut ast.InfixExpr) table.Type {
|
||||||
fn (mut c Checker) fail_if_immutable(expr ast.Expr) {
|
fn (mut c Checker) fail_if_immutable(expr ast.Expr) {
|
||||||
match expr {
|
match expr {
|
||||||
ast.Ident {
|
ast.Ident {
|
||||||
scope := c.file.scope.innermost(expr.position().pos)
|
scope := c.file.scope.innermost(it.pos.pos)
|
||||||
if v := scope.find_var(it.name) {
|
if v := scope.find_var(it.name) {
|
||||||
if !v.is_mut && !v.typ.is_ptr() {
|
if !v.is_mut && !v.typ.is_ptr() {
|
||||||
c.error('`$it.name` is immutable, declare it with `mut` to make it mutable',
|
c.error('`$it.name` is immutable, declare it with `mut` to make it mutable',
|
||||||
|
@ -490,7 +490,7 @@ fn (mut c Checker) fail_if_immutable(expr ast.Expr) {
|
||||||
ast.SelectorExpr {
|
ast.SelectorExpr {
|
||||||
// retrieve table.Field
|
// retrieve table.Field
|
||||||
if it.expr_type == 0 {
|
if it.expr_type == 0 {
|
||||||
c.error('0 type in SelectorExpr', expr.position())
|
c.error('0 type in SelectorExpr', it.pos)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
typ_sym := c.table.get_type_symbol(it.expr_type)
|
typ_sym := c.table.get_type_symbol(it.expr_type)
|
||||||
|
|
Loading…
Reference in New Issue