Closed ghost closed 11 years ago
Looks good to me.
Ambiguous match error reporting integrated into match failure system. This code:
define foo;
overload foo(x) = true;
overload foo(y:Int32) = false;
main() {
foo("bar");
foo(2);
}
produces this error (with -final-overloads):
###############################
main() {
foo("bar");
foo(2);
-----------^
}
###############################
../test/lang/overloads/final/ambiguous/main.clay(7,4): error: call matches ambiguous overloads
../test/lang/overloads/final/ambiguous/main.clay(3,0)
matched
../test/lang/overloads/final/ambiguous/main.clay(2,0)
matched
compilation context:
foo(Int32)
../test/lang/overloads/final/ambiguous/main.clay(7,4):
main()
/home/jeremy/dev/clay/clay/build/compiler/../../lib-clay/core/system/system.clay(23,30):
getExitCode()
/home/jeremy/dev/clay/clay/build/compiler/../../lib-clay/core/system/system.clay(23,26):
runMain(Int32, Pointer[Pointer[Int8]], Static[main])
/home/jeremy/dev/clay/clay/build/compiler/../../lib-clay/core/system/system.clay(39,13):
callMain(Static[main], Int32, Pointer[Pointer[Int8]])
external main
@agemogolk I like this pull request: language change is good, and implementation is also good.
Thanks @stepancheg . I'll just wait and see if @jckarter has any further comment on error messages before merging.
Reusing the match failure error code is a good idea. Looks good to me.
I find the wording quite ambitious. The word default screams for another overload, and the word overload doesn't imply a final. What is so special about the word overload that you stick to it? What about apply/final(ize), apply/set, apply/fix or apply/define? overload/final is more clear too.
Implemented final overloads as discussed in #464, #383, #334.
Final overloads are switched off by default to allow the library to be incrementally updated. A compiler flag '-final-overloads' has been added to turn final overloads on.
The library has been updated with 'default' overloads to allow the bindgen tool and hello world example to compile with final overloads enabled.
Some simple tests have been added using the -final-overloads flag.
Issues:
The ambiguous match error output is currently untidy and possibly too verbose.