Skip to content

Commit

Permalink
Better checks for missing @dynamic. Addresses #1055.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Oct 28, 2023
1 parent e17bb5f commit e4c1328
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/std/core/allocators/temp_allocator.c3
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn TempAllocator*! new_temp(usz size, Allocator* using)
return allocator;
}

fn usz TempAllocator.mark(&self) => self.used;
fn usz TempAllocator.mark(&self) @dynamic => self.used;

fn void TempAllocator.release(&self, void* old_pointer, bool) @dynamic
{
Expand Down
8 changes: 5 additions & 3 deletions src/compiler/sema_passes.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,26 +612,28 @@ static inline bool sema_check_interfaces(Decl *decl)
FOREACH_BEGIN(TypeInfo *interface_type, decl->interfaces)
Decl *interface = interface_type->type->decl;
FOREACH_BEGIN(Decl *method, interface->interface_methods)
if (method->func_decl.attr_optional) continue;
Decl *matching_method = sema_decl_stack_resolve_symbol(method->name);
if (!matching_method)
{
if (method->func_decl.attr_optional) continue;
SEMA_ERROR(interface_type, "'%s' was not fully implemented, required method '%s' needs to be implemented, did you forget it?",
interface->name, method->name);
sema_decl_stack_restore(store);
return false;
}
if (matching_method->decl_kind != DECL_FUNC)
{
if (method->func_decl.attr_optional) continue;
SEMA_ERROR(matching_method, "'%s' was not fully implemented, it requires '%s' to be a function marked '@dynamic'.",
interface->name, method->name);
sema_decl_stack_restore(store);
return false;
}
if (!matching_method->func_decl.attr_dynamic)
{
SEMA_ERROR(matching_method, "'%s' was not fully implemented, you need to mark '%s' as '@dynamic'.",
interface->name, method->name);
SEMA_ERROR(matching_method, "'%s(...)' must be marked '@dynamic' as it matches the method '%s' in interface '%s'.",
method->name, method->name, interface->name);
SEMA_NOTE(method, "Here is the interface method to implement.");
sema_decl_stack_restore(store);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define COMPILER_VERSION "0.4.690"
#define COMPILER_VERSION "0.4.691"

0 comments on commit e4c1328

Please sign in to comment.