Fix naming problem by realizing that we should allow variable shadowing anyway (anything that's not a function, that is) and we know what is and isn't a function based on the type of the binding from our type unification, so we just check to see if we're not a function type, and if so, just take our first result
This commit is contained in:
11
k.krak
11
k.krak
@@ -507,6 +507,16 @@ fun main(argc: int, argv: **char): int {
|
|||||||
work_done = true
|
work_done = true
|
||||||
println("wok done! set " + to_string(t->data))
|
println("wok done! set " + to_string(t->data))
|
||||||
} else {
|
} else {
|
||||||
|
// isn't function, by shadowing we just take the first
|
||||||
|
if !is_fun(binding_types[t]->bound_to) {
|
||||||
|
if (!multiple_binding_options[t].size > 0)
|
||||||
|
error("No possible options for " + to_string(t->data))
|
||||||
|
var it = multiple_binding_options[t][0]
|
||||||
|
set_ast_binding(t, it)
|
||||||
|
unify(binding_types[t], get_type(it))
|
||||||
|
work_done = true
|
||||||
|
} else {
|
||||||
|
// function type, so we have to get interesting
|
||||||
var filtered_options = multiple_binding_options[t].filter(fun(p: *tree<ast>): bool return equality(binding_types[t]->bound_to, get_type(p)->bound_to, true);)
|
var filtered_options = multiple_binding_options[t].filter(fun(p: *tree<ast>): bool return equality(binding_types[t]->bound_to, get_type(p)->bound_to, true);)
|
||||||
if (filtered_options.size == 0) {
|
if (filtered_options.size == 0) {
|
||||||
println("Attempting to use our inferenced type " + to_string(binding_types[t]->bound_to) + " to decide what to bind " + to_string(t->data) + " to from options:")
|
println("Attempting to use our inferenced type " + to_string(binding_types[t]->bound_to) + " to decide what to bind " + to_string(t->data) + " to from options:")
|
||||||
@@ -524,6 +534,7 @@ fun main(argc: int, argv: **char): int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (var i = children_start_index; i < t->children.size; i++;) {
|
for (var i = children_start_index; i < t->children.size; i++;) {
|
||||||
if !traverse_for_select(t->children[i]) {
|
if !traverse_for_select(t->children[i]) {
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user