Ticket #246 (new defect)

Opened 15 months ago

Last modified 15 months ago

type checker gives the wrong type to a field that is declared as an abstrct field in super trait

Reported by: angelee Owned by: EricAllen
Priority: major Milestone:
Component: static analysis Version:
Keywords: Cc:

Description

The following code snippet fails when run with fortress typecheck:

trait XTrait

v:ZZ32

end

object XObj(v:ZZ32) extends XTrait

foo():ZZ32 = v

end

with error on the reference to v in object decl XObj: Function body has type AND{()->FortressLibrary.ZZ32[\\]}, but declared return type is FortressLibrary.ZZ32[\\]

Since v is declared as an abstract field in its super trait, any reference to v within the object decl are now treated as a reference to its getter, which results a type error. The correct behavior of the code above should just type check, since the spec allows direct access to its field within an object decl.

NOTE: 1. The test case is checked into not_passing_yet 2. If the reference to v is changed to v() or self.v, the code then type checks.

Change History

Changed 15 months ago by angelee

The test file is called: typeCheckErrorForAbsFldRef.fss

Note: See TracTickets for help on using tickets.