HM-style return type overloaded function infrencing works!

This commit is contained in:
Nathan Braswell
2018-09-24 00:08:07 -04:00
parent 9178c2a29d
commit 2148577523
3 changed files with 132 additions and 53 deletions

View File

@@ -32,18 +32,6 @@ adt ast {
_cast: *binding<type>,
_value: pair<str, *binding<type>>
}
fun get_type(a: *tree<ast>): *binding<type> {
match(a->data) {
ast::_identifier(b) return b.second
ast::_binding(b) return get_type(b.second->bound_to)
ast::_function(b) return b.second
ast::_call() return get_type(a->children[0])->bound_to->base._fun.first.second
/*ast::_compiler_intrinsic(b) return str("_compiler_intrinsic(") + b.first + ")"*/
ast::_cast(b) return b
ast::_value(b) return b.second
}
error("Trying to get type of node without one: " + to_string(a->data))
}
fun to_string(a: ref ast): str {
match(a) {
ast::_translation_unit(b) return str("_translation_unit(") + b + ")"