context.options = opts;
context.cycle_detected = 0;
+ context.cycle_almost_detected = 0;
OnyxFilePos internal_location = { 0 };
internal_location.filename = "<compiler internal>";
else if (watermarked_node == ent) {
if (ent->macro_attempts > highest_watermark) {
entity_heap_insert_existing(&context.entities, ent);
- dump_cycles();
+
+ if (context.cycle_almost_detected) {
+ dump_cycles();
+ } else {
+ context.cycle_almost_detected = 1;
+ }
}
}
else if (watermarked_node->macro_attempts < ent->macro_attempts) {
}
} else {
watermarked_node = NULL;
+ context.cycle_almost_detected = 0;
}
if (onyx_has_errors()) return ONYX_COMPILER_PROGRESS_ERROR;
static SymresStatus symres_directive_defined(AstDirectiveDefined** pdefined) {
AstDirectiveDefined* defined = *pdefined;
- b32 use_package_count = (context.entities.type_count[Entity_Type_Use_Package] == 0);
+ b32 has_to_be_resolved = context.cycle_almost_detected;
resolved_a_symbol = 0;
SymresStatus ss = symres_expression(&defined->expr);
- if (use_package_count && ss != Symres_Success && !resolved_a_symbol) {
+ if (has_to_be_resolved && ss != Symres_Success && !resolved_a_symbol) {
// The symbol definitely was not found and there is no chance that it could be found.
defined->is_defined = 0;
return Symres_Success;