Ticket #38 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

ordered union type conversions

Reported by: dherman Assigned to: graydon
Type: defect Priority: major
Component: RefImpl Version: 4
Keywords: Cc:

Description (last modified by graydon) (diff)

Converting to a union type needs to search the type in order.

use namespace intrinsic;
class Foo {
    static var FOO : Foo = new Foo;
    meta public static function convert(n : int) : Foo FOO
    public function toString() : string "Foo"
}
class Bar {
    static var BAR : Bar = new Bar;
    meta public static function convert(n : int) : Bar BAR
    public function toString() : string "Bar"
}
var x : (Foo, Bar) = 42
var y : (Bar, Foo) = 42
print(x) // "Foo"
print(y) // "Bar"

Attachments

Change History

Changed 3 years ago by graydon

  • status changed from new to closed
  • resolution set to fixed
  • description changed from Converting to a union type needs to search the type in order. {{{ #!js class Foo { static let FOO : Foo = new Foo; meta public static function convert(n : int) : Foo FOO public function toString() : string "Foo" } class Bar { static var BAR : Bar = new Bar; meta public static function convert(n : int) : Bar BAR public function toString() : string "Bar" } var x : (Foo, Bar) = 42 var y : (Bar, Foo) = 42 print(x) // "Foo" print(y) // "Bar" }}} to Converting to a union type needs to search the type in order. {{{ #!js use namespace intrinsic; class Foo { static var FOO : Foo = new Foo; meta public static function convert(n : int) : Foo FOO public function toString() : string "Foo" } class Bar { static var BAR : Bar = new Bar; meta public static function convert(n : int) : Bar BAR public function toString() : string "Bar" } var x : (Foo, Bar) = 42 var y : (Bar, Foo) = 42 print(x) // "Foo" print(y) // "Bar" }}}
Note: See TracTickets for help on using tickets.