Wiki

Ticket #251 (closed defect: fixed)

Opened 14 years ago

Last modified 11 years ago

shared constructor wants to initialize instance variables of reference types

Reported by: nevdelap Owned by: Chuck
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.

Attachments

static-init-nil-chk.patch Download (1.3 KB) - added by hopscc 11 years ago.

Change History

Changed 14 years 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 (:-) )

Changed 11 years ago by hopscc

Changed 11 years ago by hopscc

  • status changed from new to assigned
  • owner set to Chuck

mismatch in initializer sharedness and decls to nil check.
fix and above test added.

Changed 11 years ago by Charles

  • status changed from assigned to closed
  • resolution set to fixed

Applied in changeset:2949

Note: See TracTickets for help on using tickets.