Wiki

Ticket #378 (new defect)

Opened 3 years ago

Last modified 3 years ago

CIE by incomplete `StreamType` construction.

Reported by: thriwkin Owned by:
Priority: critical Milestone:
Component: Cobra Compiler Version: 0.9.6
Keywords: CIE Cc:

Description

Cobra svn:3116 throws this CIE

error: COBRA INTERNAL ERROR / NullReferenceException / 
  Object reference not set to an instance of an object.

when compiling this program:

class Program
    shared
        def m<of T> as T*
            return T[](0)
        def main
            x = .m<of int>
            CobraCore.noOp(x)

Attachments

ticket-cmt2-Examples.cobra Download (1.4 KB) - added by thriwkin 3 years ago.
More examples
StreamType-construction.patch Download (501 bytes) - added by thriwkin 3 years ago.

Change History

Changed 3 years ago by thriwkin

More examples

Changed 3 years ago by thriwkin

I think, the program above should be compilable.

The critcal code pattern is this:

    def m<of T>(...) as T*
        ...
    def mm
        a = .m<of Foo>(...)
        ...

Some more meaningful examples, which all use this pattern,
are in the attached file.

Changed 3 years ago by thriwkin

Changed 3 years ago by thriwkin

Is this a possible bug fix?

I added this code to the compiler source:

class StreamType : WrappedType
    def secondaryConstructedTypeFor(box as Box, gpToType as Dictionary<of GenericParam, IType>) as IType is override
        t = StreamType(_wrappedType.secondaryConstructedTypeFor(box, gpToType))
        t.bindInh
        t.bindInt
        return t

Then I installed the modified source with "install-from-workspace"
and tested again:
1. All examples above can be compiled, without CIE, and run as expected.
2. "cobra -testify" does not report more failures as before.
3. The patched compiler can compile its source.

Note: See TracTickets for help on using tickets.