this post was submitted on 10 Oct 2024
107 points (94.2% liked)

Programmer Humor

19623 readers
2342 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
top 12 comments
sorted by: hot top controversial new old
[–] [email protected] 17 points 1 month ago* (last edited 1 month ago) (2 children)

I mean, the type system isn’t very strict at all to begin with in some . It’s trivially breakable when performing common operations like type punning in C.

[–] Korne127 13 points 1 month ago

Depends on the programming language

[–] [email protected] 3 points 1 month ago

That's why we don't like c

[–] [email protected] 9 points 1 month ago (1 children)
[–] qaz 23 points 1 month ago (2 children)

I broke the type system in Kotlin and ended up with a null value in a non-null (not lateinit) variable.

[–] [email protected] 6 points 1 month ago

How convoluted was it?

[–] [email protected] 1 points 1 month ago (1 children)

With no platform types involved?

[–] qaz 1 points 1 month ago (1 children)
[–] [email protected] 1 points 1 month ago (1 children)

Interesting. Care to share? I think they fixed a few of those issues with K2. Did you find something new or is it known?

[–] qaz 3 points 1 month ago* (last edited 1 month ago) (1 children)

It was about 3 years ago, and I haven't been able to find my old code again. I probably discarded it after finding out it didn't work well. I was able to find this screenshot though:

[–] [email protected] 3 points 1 month ago

Uh. Probably not exactly your case, but I managed to "reproduce" them.

The first case is easy if you just override the setter of a property, and is more a feature of the language rather than a bug.

The second case is more tricky, but by using a generic delegate you can manage to trick it by doing an unchecked cast. Got the same warning in IntelliJ as well.

Link: https://pl.kotl.in/pIt-uHw7d

[–] [email protected] 2 points 1 month ago

Heinz Doofenshmirtz as senior dev