-
-
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 assign expected type on rechecking enum assigns (fix #23366
) (#23367)
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
pub type FnGridObject = fn (mut object GridObject) | ||
|
||
@[flag] | ||
pub enum GridObjectAuto { | ||
drag | ||
drop | ||
scale_on_hover | ||
pickup | ||
sound | ||
off // auto "deactivation" | ||
} | ||
|
||
@[params] | ||
pub struct GridObjectConfig { | ||
auto GridObjectAuto = ~GridObjectAuto.zero() | ||
on ?FnGridObject | ||
} | ||
|
||
@[heap] | ||
struct GridObject { | ||
mut: | ||
config GridObjectConfig | ||
auto GridObjectAuto = ~GridObjectAuto.zero() | ||
} | ||
|
||
pub fn on(config GridObjectConfig) &GridObject { | ||
mut ob := &GridObject{} | ||
ob.config = config | ||
ob.auto = config.auto | ||
if func := ob.config.on { | ||
func(mut ob) | ||
} | ||
return ob | ||
} | ||
|
||
fn test_main() { | ||
_ := on( | ||
on: fn (mut o GridObject) { | ||
o.auto = .off | .pickup | .sound | ||
} | ||
) | ||
assert true | ||
} |