Template function instantiation type inference work - super simple inference works (i.e. id<T>(i:T) { return i; }), and the framework is good, just have to flesh out unifyType to handle more than the trivial case
This commit is contained in:
2
tests/test_templateFuncInfr.expected_results
Normal file
2
tests/test_templateFuncInfr.expected_results
Normal file
@@ -0,0 +1,2 @@
|
||||
11
|
||||
12
|
||||
17
tests/test_templateFuncInfr.krak
Normal file
17
tests/test_templateFuncInfr.krak
Normal file
@@ -0,0 +1,17 @@
|
||||
import io:*
|
||||
import mem:*
|
||||
import vector:*
|
||||
|
||||
fun id<T>(in: T): T { return in; }
|
||||
fun idVec<T>(in: vector<T>): T { return in.get(0); }
|
||||
|
||||
fun main():int {
|
||||
var fromTemplateFun = id(11)
|
||||
var aVec.construct(): vector<int>
|
||||
aVec.addEnd(12)
|
||||
//var fromTemplateFun = id<int>(11);
|
||||
println(fromTemplateFun)
|
||||
println(idVec(aVec))
|
||||
//println(idVec<int>(aVec))
|
||||
return 0
|
||||
}
|
||||
@@ -28,14 +28,14 @@ fun main():int {
|
||||
var add = 9 + 3
|
||||
var flt = 9.3
|
||||
var msg = retMessage()
|
||||
var fromTemplateFun = id<int>(11);
|
||||
var fromTemplateFun = id(11);
|
||||
var vec = new<vector<int>>()->construct()
|
||||
vec->addEnd(avar)
|
||||
|
||||
var src: CustomObj
|
||||
src.data = 80
|
||||
var dst = src
|
||||
var throughTemp = inFun<char*>("complicated");
|
||||
var throughTemp = inFun("complicated");
|
||||
|
||||
println(str)
|
||||
println(avar)
|
||||
|
||||
Reference in New Issue
Block a user