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:
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
|
||||
}
|
||||
Reference in New Issue
Block a user