carp-lang / Carp

A statically typed lisp, without a GC, for real-time applications.
Apache License 2.0
5.52k stars 173 forks source link

Bug with REPL displaying result of calling function that returns Char #1422

Open komos90 opened 2 years ago

komos90 commented 2 years ago

Just playing around with the language and stumbled on this in the REPL:

> \S
=> \S
> (defn f [] \S)
> (f)
I can’t find any implementation for the interface `str` of type (Fn [(Ref Char t7)] String) at line 503, column 10 in '/home/seoras/Software/carp-v0.5.5-x86_64-linux/core/String.carp'.

None of the possibilities have the correct signature:
    Array.str : (Fn [(Ref (Array a) q)] String)
    StaticArray.str : (Fn [(Ref (StaticArray a) q)] String)
    Box.str : (Fn [(Ref (Box t) q)] String)
    Function.Arity0.str : (Fn [(Ref (Fn [] z) q)] String)
    Function.Arity1.str : (Fn [(Ref (Fn [d] z) q)] String)
    Function.Arity2.str : (Fn [(Ref (Fn [d, e] z) q)] String)
    Function.Arity3.str : (Fn [(Ref (Fn [d, e, f] z) q)] String)
    Function.Arity4.str : (Fn [(Ref (Fn [d, e, f, g] z) q)] String)
    Function.Arity5.str : (Fn [(Ref (Fn [d, e, f, g, h] z) q)] String)
    Function.Arity6.str : (Fn [(Ref (Fn [d, e, f, g, h, i] z) q)] String)
    Function.Arity7.str : (Fn [(Ref (Fn [d, e, f, g, h, i, j] z) q)] String)
    Function.Arity8.str : (Fn [(Ref (Fn [d, e, f, g, h, i, j, k] z) q)] String)
    Function.Arity9.str : (Fn [(Ref (Fn [d, e, f, g, h, i, j, k, l] z) q)] String)
    Maybe.str : (Fn [(Ref (Maybe a) q)] String)
    Result.str : (Fn [(Ref (Result a b) q)] String)
    Pair.str : (Fn [(Ref (Pair a b) q)] String)
    Triple.str : (Fn [(Ref (Triple a b c) q)] String)
    Quadruple.str : (Fn [(Ref (Quadruple a b c d) q)] String)
    PtrChar.str : (Fn [(Ptr Char)] String)
    String.str : (Fn [(Ref String tyvar-from-info-0_23_30)] String)
    StringCopy.str : (Fn [String] String)
    Bool.str : (Fn [Bool] String)
    Int.str : (Fn [Int] String)
    Byte.str : (Fn [Byte] String)
    Float.str : (Fn [Float] String)
    Long.str : (Fn [Long] String)
    Double.str : (Fn [Double] String)
    Char.str : (Fn [Char] String)
    IntRef.str : (Fn [(Ref Int a)] String)
    BoolRef.str : (Fn [(Ref Bool a)] String)
    ByteRef.str : (Fn [(Ref Byte a)] String)
    LongRef.str : (Fn [(Ref Long a)] String)
    FloatRef.str : (Fn [(Ref Float a)] String)
    DoubleRef.str : (Fn [(Ref Double a)] String)
    Int8.str : (Fn [Int8] String)
    Int8Extra.str : (Fn [(Ref Int8 a)] String)
    Int16.str : (Fn [Int16] String)
    Int16Extra.str : (Fn [(Ref Int16 a)] String)
    Int32.str : (Fn [Int32] String)
    Int32Extra.str : (Fn [(Ref Int32 a)] String)
    Int64.str : (Fn [Int64] String)
    Int64Extra.str : (Fn [(Ref Int64 a)] String)
    Uint8.str : (Fn [Uint8] String)
    Uint8Extra.str : (Fn [(Ref Uint8 a)] String)
    Uint16.str : (Fn [Uint16] String)
    Uint16Extra.str : (Fn [(Ref Uint16 a)] String)
    Uint32.str : (Fn [Uint32] String)
    Uint32Extra.str : (Fn [(Ref Uint32 a)] String)
    Uint64.str : (Fn [Uint64] String)
    Uint64Extra.str : (Fn [(Ref Uint64 a)] String)
    Pointer.str : (Fn [(Ptr a)] String)
    Pattern.MatchResult.str : (Fn [Pattern.MatchResult] String)
    Pattern.MatchResult.ref-str : (Fn [(Ref Pattern.MatchResult a)] String)
    Pattern.str : (Fn [(Ref Pattern tyvar-from-info-0_89_23)] String)
    Bucket.str : (Fn [(Ref (Bucket a b) q)] String)
    Map.str : (Fn [(Ref (Map a b) c)] String)
    SetBucket.str : (Fn [(Ref (SetBucket a) q)] String)
    Set.str : (Fn [(Ref (Set a) b)] String)
    ByteOrder.str : (Fn [(Ref ByteOrder q)] String)
    Opaque.str : (Fn [(Ref Opaque q)] String) at dummy-file:0:0.
> ((fn [] \S))
=> \S
> ((fn [] (f)))
^C

The last line hangs and starts using up all the RAM.

eriksvedang commented 2 years ago

Thanks for reporting! The message is correct (we need an interface implementation of str for chars) but the hang is obviously a bug.