Wiki

Ticket #251 (new defect)

Opened 17 months ago

Last modified 17 months ago

shared constructor wants to initialize instance variables of reference types

Reported by: nevdelap Owned by:
Priority: medium Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

class A

    var isntShared as String

    cue init
        base.init
        .isntShared = '1'

    shared

        var isShared as String

        cue init
            .isShared = '2'

class P

    def main is shared
        assert A().isntShared == '1'
        assert A.isShared     == '2'

test.cobra(16): error: Cannot access instance member "isntShared" from the current shared member. Make the member "shared" or create an instance of the type.

If the strings are changed to a class the result is the same. If the strings are changed to int, or a struct it is ok.

Hopefully starting in October I will have time to start fixing bugs instead of just reporting them.

Change History

Changed 17 months ago by hopscc

  • priority changed from minor to medium

Its from nilcheck code in the static initialiser.
Looks like its adding nilchecks for the non static fields instead of (just) the static ones and subsequent check on validity fails.

(Indicates how much anyone uses cobra with static initialisers (:-) )

Note: See TracTickets for help on using tickets.