mirror of
https://github.com/vlang/v.git
synced 2025-09-16 10:57:25 -04:00
This commit is contained in:
parent
b1f64a32e3
commit
41d38d735a
@ -735,8 +735,7 @@ or use an explicit `unsafe{ a[..] }`, if you do not want a copy of the slice.',
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !is_blank_ident && right_sym.kind != .placeholder && left_sym.kind != .interface_
|
if !is_blank_ident && right_sym.kind != .placeholder && left_sym.kind != .interface_ {
|
||||||
&& !right_type.has_flag(.generic) && !left_type.has_flag(.generic) {
|
|
||||||
// Dual sides check (compatibility check)
|
// Dual sides check (compatibility check)
|
||||||
c.check_expected(right_type_unwrapped, left_type_unwrapped) or {
|
c.check_expected(right_type_unwrapped, left_type_unwrapped) or {
|
||||||
// allow literal values to auto deref var (e.g.`for mut v in values { v = 1.0 }`)
|
// allow literal values to auto deref var (e.g.`for mut v in values { v = 1.0 }`)
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
vlib/v/checker/tests/assign_type_mismatch_with_generics_err.vv:13:9: error: cannot assign to `b`: expected `bool`, not `fn (Bar) bool`
|
||||||
|
11 | mut b := false
|
||||||
|
12 | if f.f != none {
|
||||||
|
13 | b = f.f or { panic(err) }
|
||||||
|
| ^
|
||||||
|
14 | } else {
|
||||||
|
15 | b = true
|
@ -0,0 +1,28 @@
|
|||||||
|
type Fn[T] = fn (arg T) bool
|
||||||
|
|
||||||
|
struct Foo[T] {
|
||||||
|
f ?Fn[T]
|
||||||
|
}
|
||||||
|
|
||||||
|
@[params]
|
||||||
|
struct Bar {}
|
||||||
|
|
||||||
|
fn (mut f Foo[T]) method(arg T) {
|
||||||
|
mut b := false
|
||||||
|
if f.f != none {
|
||||||
|
b = f.f or { panic(err) }
|
||||||
|
} else {
|
||||||
|
b = true
|
||||||
|
}
|
||||||
|
if b {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
mut foo := Foo[Bar]{
|
||||||
|
f: fn (arg Bar) bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foo.method(Bar{})
|
||||||
|
}
|
@ -35,8 +35,8 @@ pub fn (mut ec EventController[T]) emit(e T, options EmitOptions) {
|
|||||||
for i, w in ec.wait_fors {
|
for i, w in ec.wait_fors {
|
||||||
mut b := false
|
mut b := false
|
||||||
if w.check != none {
|
if w.check != none {
|
||||||
b = (w.check or { panic(err) })
|
func := w.check or { panic(err) }
|
||||||
e
|
b = func(e)
|
||||||
} else {
|
} else {
|
||||||
b = true
|
b = true
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user