~duangle/scopes#11: 
under certain circumstances, an Rc copy can become corrupted

repro:

using import Array
using import Rc
using import enum

enum StorageKind
    Pointer : (Rc this-type)
    Function : (Rc (Array this-type))
    TypeReference : Symbol

    inline __copy (self)
        'apply self
            inline (T ...)
                # uncomment next line to see corruption
                # print ...
                T
                    va-map
                        inline (arg)
                            copy arg
                        ...

fn myfn (n)
    returning (uniqueof StorageKind -1)

    # ONLY HAPPENS WITH MATCH! NO SWITCH
    match n
    case 0
        let newST =
            copy
                this-function (n + 1)
        StorageKind.Pointer (Rc.wrap newST)
    case 1
        local args : (Array StorageKind)
        'append args
            copy
                this-function (n + 1)
        # doesn't happen without this return.
        return
            StorageKind.Function (Rc.wrap (deref args))
    default
        StorageKind.TypeReference 'unknown

myfn 0
none
Status
RESOLVED FIXED
Submitter
~radgerayden
Assigned to
No-one
Submitted
2 years ago
Updated
1 year, 10 months ago
Labels
No labels applied.

~radgerayden REPORTED FIXED 1 year, 10 months ago

Doesn't reproduce anymore. Probably fixed together with #12.

Register here or Log in to comment, or comment via email.