An unofficial, read-only Hacker News reader. Join the beta →

I checked Clojure's core with Lean and found unreported bugs (opens external site)

238 points by encyclopedism 2 days ago | s.conao3.com | 84 comments on HN

View full thread · View on Hacker News

Comment thread (13)

  1. I'm not sure the lisp community could consider these bugs.

    Lisp/clojure/scheme etc is inherently untyped. These libs don't guarantee anything near to the level that a formal verification would suggest.

    If this were the haskell standard lib however, that would be news.

    Replies (6)
    1. Some of these issues are actually quite bad and don't have anything to do with types at all
    2. The article I read described clear correctness bugs unrelated to types.
    3. Lisp is not untyped. It is dynamically typed.
      Replies (3)
      1. Or as Bob Harper would say, unityped.
        Replies (1)
        1. That is an ignorant concept which conflates the implementation level with the program's abstraction.

          At the implementation level, there exist storage locations (which we might call "value cells"). These can hold any value and so in a sense they have one type.

          The abstract nodes of the program, its expressions, have a type we can reason about. Often a single type that can be known without executing the program..

          Static functional languages, too, have typeless value cells in their implementations: word-sized units of storage that can point to anything and may have type tags, gc bits and whatnot. The difference is that nodes of the abstract program are checked.

          Dynamic languages have type inference implementations also. The situation is not so strict that an uncheckable program may not be executed, though.

      2. Common Lisp is strongly typed.

        I understand Clojure is strongly typed too.

      3. "Untyped" is a political word used by type theorists in computer science to refer to computing paradigms which do not traverse the nodes of the program to assign each one of them a single unambiguous type before proceeding to execution.

        It means Not True Scotsman Typed.

        You can't think of it as "lacking type information"; watch out: that's a trap laid to reveal you as a n00b who doesn't speak the lingo.

    4. I'm glad I checked your other comments! Beautiful counter bait
    5. Types have nothing to do with it. For example, the first bug in the article is about an infinite loop in a core data structure:

      “[…] reduce it, the call never returns once the vector has 65505 or more elements.”

      > These libs don't guarantee anything near to the level that a formal verification would suggest.

      This is just plain wrong. A lisp library can absolutely make performance and correctness guarantees, and formal methods can refute or verify those guarantees. A type system is just a special kind of formal method that can rule out certain classes of bugs.

    6. Even the types in Haskell are far too weak to be included in what we mean by "formal verification" (not to say they're not useful for some things, just that this is not the level of specification that formal verification is typically about). If we rank the strength of properties we can express with types in Clojure as 0 and in Haskell as 3 (or, say, 7 with refinement types), then the strength of types required for formal verification (e.g. in a language like Idris) would be 100.
      Replies (2)
      1. Indeed. I’ve viewed Haskell not as a high bar to clear. It’s rather low. And most languages don’t even clear it.

        Things trickle down to Haskell from higher up but it takes a long time to incorporate them. Dependent Haskell has been in the making for like… 9 years? Maybe more? And it’s still being debated whether Haskell should even adopt it.

        The type theory needed for formal proofs is much more advanced at this point. Idris, Agda, Lean, Roq… this is where you need to look to see the 100’s.

      2. Idris and Haskell are not that far apart lol