• henfredemars@infosec.pub
    link
    fedilink
    English
    arrow-up
    15
    ·
    edit-2
    2 months ago

    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.

    • qaz@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      22
      ·
      2 months ago

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

          • MMauro
            link
            fedilink
            arrow-up
            1
            ·
            2 months ago

            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@lemmy.worldOP
              link
              fedilink
              English
              arrow-up
              2
              ·
              edit-2
              1 month ago

              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:

              • MMauro
                link
                fedilink
                arrow-up
                1
                ·
                2 months 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