fmt: x.foo!() experiment
parent
e5f12ad74a
commit
2770077cb0
|
@ -245,7 +245,6 @@ pub:
|
|||
pub mut:
|
||||
name string
|
||||
is_method bool
|
||||
is_mut bool // !
|
||||
args []CallArg
|
||||
expected_arg_types []table.Type
|
||||
language table.Language
|
||||
|
|
|
@ -799,7 +799,7 @@ pub fn (mut c Checker) call_method(mut call_expr ast.CallExpr) table.Type {
|
|||
}
|
||||
if method.args[0].is_mut {
|
||||
c.fail_if_immutable(call_expr.left)
|
||||
call_expr.is_mut = true
|
||||
// call_expr.is_mut = true
|
||||
}
|
||||
if method.return_type == table.void_type && method.ctdefine.len > 0 && method.ctdefine !in
|
||||
c.pref.compile_defines {
|
||||
|
|
|
@ -888,6 +888,24 @@ pub fn (mut f Fmt) call_expr(node ast.CallExpr) {
|
|||
}
|
||||
*/
|
||||
if node.is_method {
|
||||
/*
|
||||
// x.foo!() experiment
|
||||
mut is_mut := false
|
||||
if node.left is ast.Ident {
|
||||
scope := f.file.scope.innermost(node.pos.pos)
|
||||
x := node.left as ast.Ident
|
||||
var := scope.find_var(x.name) or {
|
||||
panic(err)
|
||||
}
|
||||
println(var.typ)
|
||||
if var.typ != 0 {
|
||||
sym := f.table.get_type_symbol(var.typ)
|
||||
if method := f.table.type_find_method(sym, node.name) {
|
||||
is_mut = method.args[0].is_mut
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
if node.left is ast.Ident {
|
||||
it := node.left as ast.Ident
|
||||
// `time.now()` without `time imported` is processed as a method call with `time` being
|
||||
|
@ -910,7 +928,7 @@ pub fn (mut f Fmt) call_expr(node ast.CallExpr) {
|
|||
f.write('.' + node.name + '(')
|
||||
f.call_args(node.args)
|
||||
f.write(')')
|
||||
if node.is_mut {
|
||||
if is_mut {
|
||||
// f.write('!')
|
||||
}
|
||||
f.or_expr(node.or_block)
|
||||
|
|
Loading…
Reference in New Issue