aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-11-25 17:57:49 +0000
committergingerBill <bill@gingerbill.org>2018-11-25 17:57:49 +0000
commit9b063ad9a3a3b4da52ac4d60c65a0ff7c8dd79cf (patch)
tree0ebe8ee21e649e711a1c1d0a47f488790f6c38de /src
parentc2f9bf489eb3ae7296cf1d255ab2da1037b005b4 (diff)
Fix poly proc determination by cloning the signature node
Diffstat (limited to 'src')
-rw-r--r--src/check_expr.cpp6
-rw-r--r--src/gb/gb.h13
-rw-r--r--src/ir.cpp25
3 files changed, 23 insertions, 21 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 47b741f40..28271efb8 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -278,7 +278,6 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *c, Entity *base_enti
return false;
}
-
auto *found_gen_procs = map_get(&nctx.info->gen_procs, hash_pointer(base_entity->identifier));
if (found_gen_procs) {
auto procs = *found_gen_procs;
@@ -304,13 +303,14 @@ bool find_or_generate_polymorphic_procedure(CheckerContext *c, Entity *base_enti
// NOTE(bill): Reset scope from the failed procedure type
scope_reset(scope);
- success = check_procedure_type(&nctx, final_proc_type, pt->node, &operands);
+ // LEAK TODO(bill): Cloning this AST may be leaky
+ Ast *cloned_proc_type_node = clone_ast(pt->node);
+ success = check_procedure_type(&nctx, final_proc_type, cloned_proc_type_node, &operands);
if (!success) {
return false;
}
-
if (found_gen_procs) {
auto procs = *found_gen_procs;
for_array(i, procs) {
diff --git a/src/gb/gb.h b/src/gb/gb.h
index 79cb32d76..0243405db 100644
--- a/src/gb/gb.h
+++ b/src/gb/gb.h
@@ -763,7 +763,7 @@ extern "C++" {
#ifndef GB_ASSERT_MSG
#define GB_ASSERT_MSG(cond, msg, ...) do { \
if (!(cond)) { \
- gb_assert_handler(#cond, __FILE__, cast(i64)__LINE__, msg, ##__VA_ARGS__); \
+ gb_assert_handler("Assertion Failure", #cond, __FILE__, cast(i64)__LINE__, msg, ##__VA_ARGS__); \
GB_DEBUG_TRAP(); \
} \
} while (0)
@@ -779,10 +779,13 @@ extern "C++" {
// NOTE(bill): Things that shouldn't happen with a message!
#ifndef GB_PANIC
-#define GB_PANIC(msg, ...) GB_ASSERT_MSG(0, msg, ##__VA_ARGS__)
+#define GB_PANIC(msg, ...) do { \
+ gb_assert_handler("Panic", NULL, __FILE__, cast(i64)__LINE__, msg, ##__VA_ARGS__); \
+ GB_DEBUG_TRAP(); \
+} while (0)
#endif
-GB_DEF void gb_assert_handler(char const *condition, char const *file, i32 line, char const *msg, ...);
+GB_DEF void gb_assert_handler(char const *prefix, char const *condition, char const *file, i32 line, char const *msg, ...);
@@ -3613,8 +3616,8 @@ extern "C" {
#pragma warning(disable:4127) // Conditional expression is constant
#endif
-void gb_assert_handler(char const *condition, char const *file, i32 line, char const *msg, ...) {
- gb_printf_err("%s(%d): Assert Failure: ", file, line);
+void gb_assert_handler(char const *prefix, char const *condition, char const *file, i32 line, char const *msg, ...) {
+ gb_printf_err("%s(%d): %s: ", file, line, prefix);
if (condition)
gb_printf_err( "`%s` ", condition);
if (msg) {
diff --git a/src/ir.cpp b/src/ir.cpp
index b012e67b7..52b97e28d 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -2593,21 +2593,20 @@ irDebugInfo *ir_add_debug_info_proc(irProcedure *proc) {
irDebugInfo *ir_add_debug_info_location(irModule *m, Ast *node, irDebugInfo *scope, Entity *e) {
if (node == nullptr || scope == nullptr) {
- if (e == nullptr) {
- return nullptr;
- } else if (scope != nullptr) {
- irDebugInfo **existing = map_get(&m->debug_info, hash_entity(e));
- if (existing != nullptr) {
- return *existing;
- }
+ if (e != nullptr && scope != nullptr) {
+ // irDebugInfo **existing = map_get(&m->debug_info, hash_entity(e));
+ // if (existing != nullptr) {
+ // return *existing;
+ // }
- // TODO HACK(bill): This is a little dirty but it is should do for the weird edge cases
- irDebugInfo *di = ir_alloc_debug_info(irDebugInfo_Location);
- di->Location.pos = e->token.pos;
- di->Location.scope = scope;
- map_set(&m->debug_info, hash_entity(e), di);
- return di;
+ // // TODO HACK(bill): This is a little dirty but it is should do for the weird edge cases
+ // irDebugInfo *di = ir_alloc_debug_info(irDebugInfo_Location);
+ // di->Location.pos = e->token.pos;
+ // di->Location.scope = scope;
+ // map_set(&m->debug_info, hash_entity(e), di);
+ // return di;
}
+ return nullptr;
}
// TODO(lachsinc): Should we traverse the node/children until we find one with
// valid token/pos and use that instead??