-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: fix
f: app.method
field initialisation, for fn fields, ini…
…tialised with generic methods (#22665)
- Loading branch information
Showing
3 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
struct Struct { | ||
f fn (f64) f64 = unsafe { nil } | ||
} | ||
|
||
struct App {} | ||
|
||
pub fn (mut a App) frame(dt f64) f64 { | ||
dump(voidptr(a)) | ||
dump(dt) | ||
return dt | ||
} | ||
|
||
fn generic_f[T](mut ctx T) ! { | ||
s := Struct{ | ||
f: unsafe { ctx.frame } | ||
} | ||
assert s.f(1.2) == 1.2 | ||
} | ||
|
||
fn test_main() { | ||
mut app := &App{} | ||
generic_f(mut app)! | ||
assert true | ||
} |