Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error "impossible type switch case: sdl.QuitEvent" #15

Open
chrplr opened this issue Apr 15, 2024 · 7 comments
Open

Compile error "impossible type switch case: sdl.QuitEvent" #15

chrplr opened this issue Apr 15, 2024 · 7 comments

Comments

@chrplr
Copy link

chrplr commented Apr 15, 2024

When trying to compile examples/keyboard-input/keyboard-input.go, I get the following error:


impossible type switch case: sdl.QuitEvent
event (variable of type sdl.Event) cannot have dynamic type sdl.QuitEvent

This is due to a change following the commit "examples: updated to remove pointer in event switch cases" where "*sdl.QuitEvent" was replaced by "sdl.QuitEvent" in the switch statement.

If I put back the dereferencing operator '*', the code compiles.

There must be a good reason for the change in the commit. Could you explain the rationale please? Thank you in advance !

If that matters, I am using go1.22.2 linux/amd64

@veeableful
Copy link
Contributor

Hi @chrplr, the API was changed in v0.5.x so the example was updated as well. Could you try the examples referenced by v0.4.x?

@chrplr
Copy link
Author

chrplr commented Apr 15, 2024

Ah! Sorry. Indeed. I copied the example directly from the current https://github.com/veandco/go-sdl2-examples
and the go.mod file generated by the command go mod tidy on my computer contains

require github.com/veandco/go-sdl2 v0.4.38

I need to better understand how go mod tidy decides about the version...

Thanks a lot for go-sdl2 !

@chrplr chrplr closed this as completed Apr 15, 2024
@chrplr
Copy link
Author

chrplr commented Apr 15, 2024

Ah! Now, after running go get -v github.com/veandco/go-sdl2/sdl@master to obtain v0.5.0

my go.mod contains

require github.com/veandco/go-sdl2 v0.5.0-alpha.4.0.20240326043848-74189f852a83

but then compiling keyboard-input.go from examples yields:

./keyb.go:36:10: invalid case sdl.KMOD_LALT in switch on t.Keysym.Mod (mismatched types sdl.Keymod and uint16)
./keyb.go:38:10: invalid case sdl.KMOD_LCTRL in switch on t.Keysym.Mod (mismatched types sdl.Keymod and uint16)
./keyb.go:40:10: invalid case sdl.KMOD_LSHIFT in switch on t.Keysym.Mod (mismatched types sdl.Keymod and uint16)
./keyb.go:42:10: invalid case sdl.KMOD_LGUI in switch on t.Keysym.Mod (mismatched types sdl.Keymod and uint16)
./keyb.go:44:10: invalid case sdl.KMOD_RALT in switch on t.Keysym.Mod (mismatched types sdl.Keymod and uint16)
./keyb.go:46:10: invalid case sdl.KMOD_RCTRL in switch on t.Keysym.Mod (mismatched types sdl.Keymod and uint16)
./keyb.go:48:10: invalid case sdl.KMOD_RSHIFT in switch on t.Keysym.Mod (mismatched types sdl.Keymod and uint16)
./keyb.go:50:10: invalid case sdl.KMOD_RGUI in switch on t.Keysym.Mod (mismatched types sdl.Keymod and uint16)
./keyb.go:52:10: invalid case sdl.KMOD_NUM in switch on t.Keysym.Mod (mismatched types sdl.Keymod and uint16)
./keyb.go:54:10: invalid case sdl.KMOD_CAPS in switch on t.Keysym.Mod (mismatched types sdl.Keymod and uint16)

@chrplr chrplr reopened this Apr 15, 2024
@veeableful
Copy link
Contributor

Hi @chrplr, thanks for reporting it! The issue was in the v0.5.x code which I have fixed in the latest commit. You can use it by modiying the version in go.mod to 374428a92051 and then run go mod tidy.

@iweave1
Copy link

iweave1 commented Sep 13, 2024

Hi @chrplr, thanks for reporting it! The issue was in the v0.5.x code which I have fixed in the latest commit. You can use it by modiying the version in go.mod to 374428a92051 and then run go mod tidy.

Since go-sdl2 is still only on v0.4.0 release, I have to ask what are you talking about?
I confirm on v0.4.0 the deference is required to compile.

@veeableful
Copy link
Contributor

Hi @iweave1, I was referring to the master branch code which is to be v0.5.x.

@iweave1
Copy link

iweave1 commented Sep 14, 2024

Hi @iweave1, I was referring to the master branch code which is to be v0.5.x.

Thank you for clarifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants