jckarter / clay

The Clay programming language
http://claylabs.com/clay
Other
404 stars 34 forks source link

record static value parameter gets unwrapped #494

Open stepancheg opened 11 years ago

stepancheg commented 11 years ago

Code:

record Foo[A] (
    a: Type(A),
);

main() {
    var foo = Foo[#1]();
    if (foo.a != #1) // <-- compilation fails at this line
        return 1;
    if (Type(foo.a) != Type(#1))
        return 2;
    return 0;
}

Compilation fails with message:

###############################
}

forceinline default (!=)(a, b) : Bool = not (==)(a, b);
------------------------------------------------^

define ordered?;
###############################
/Users/yozh/devel/left/clay/build/compiler/../../lib-clay/core/operators/operators.clay(133,48): error: no matching overload found
... skippped
    65 universal overloads not shown (show with -full-match-errors option)

compilation context:
    ==(Int32, Static[1])
  /Users/yozh/devel/left/clay/build/compiler/../../lib-clay/core/operators/operators.clay(133,48):
    !=(Int32, Static[1])
  /Users/yozh/devel/left/clay/build/compiler/../../lib-clay/core/operators/operators.clay(432,18):
    infixOperator(Int32, Static[!=], Static[1])
  lang/records/params/static-int-param/test.clay(7,14):
    main()
  /Users/yozh/devel/left/clay/build/compiler/../../lib-clay/core/system/system.clay(23,30):
    getExitCode(Int32)
  /Users/yozh/devel/left/clay/build/compiler/../../lib-clay/core/system/system.clay(23,26):
    runMain(Int32, Pointer[Pointer[Int8]], Static[main])
  /Users/yozh/devel/left/clay/build/compiler/../../lib-clay/core/system/system.clay(39,13):
    callMain(Static[main], Int32, Pointer[Pointer[Int8]])
    external main

It means that foo.a has type Int32, but type of foo.a should be Static[1], because record type parameter is #1.

Similar code with 1, not #1 parameter works properly, see commit e6488ffc2883ae075a400b8d6f934cf8445db2da.