@@ -629,9 +629,12 @@ int loader_impl_load_from_file(loader_impl impl, const loader_naming_path paths[
629629 {
630630 if (interface_impl -> discover (impl , handle_impl -> module , handle_impl -> ctx ) == 0 )
631631 {
632- // TODO: Check if is contained in the context
633- // if (context_contains(impl->ctx, handle_impl->ctx) == 0 && context_append...)
634- if (context_append (impl -> ctx , handle_impl -> ctx ) == 0 )
632+ if (context_contains (impl -> ctx , handle_impl -> ctx ) == 0 )
633+ {
634+ /* TODO: This still does not protect duplicated names between different loaders global scope */
635+ log_write ("metacall" , LOG_LEVEL_ERROR , "There are duplicated symbols already loaded in the global scope conflicting with handle: %s" , module_name );
636+ }
637+ else if (context_append (impl -> ctx , handle_impl -> ctx ) == 0 )
635638 {
636639 static const char func_init_name [] = LOADER_IMPL_FUNCTION_INIT ;
637640
@@ -734,9 +737,12 @@ int loader_impl_load_from_memory(loader_impl impl, const char *buffer, size_t si
734737 {
735738 if (interface_impl -> discover (impl , handle_impl -> module , handle_impl -> ctx ) == 0 )
736739 {
737- // TODO: Check if is contained in the context
738- // if (context_contains(impl->ctx, handle_impl->ctx) == 0 && context_append...)
739- if (context_append (impl -> ctx , handle_impl -> ctx ) == 0 )
740+ if (context_contains (impl -> ctx , handle_impl -> ctx ) == 0 )
741+ {
742+ /* TODO: This still does not protect duplicated names between different loaders global scope */
743+ log_write ("metacall" , LOG_LEVEL_ERROR , "There are duplicated symbols already loaded in the global scope conflicting with handle: %s" , name );
744+ }
745+ else if (context_append (impl -> ctx , handle_impl -> ctx ) == 0 )
740746 {
741747 static const char func_init_name [] = LOADER_IMPL_FUNCTION_INIT ;
742748
@@ -808,9 +814,12 @@ int loader_impl_load_from_package(loader_impl impl, const loader_naming_path pat
808814 {
809815 if (interface_impl -> discover (impl , handle_impl -> module , handle_impl -> ctx ) == 0 )
810816 {
811- // TODO: Check if is contained in the context
812- // if (context_contains(impl->ctx, handle_impl->ctx) == 0 && context_append...)
813- if (context_append (impl -> ctx , handle_impl -> ctx ) == 0 )
817+ if (context_contains (impl -> ctx , handle_impl -> ctx ) == 0 )
818+ {
819+ /* TODO: This still does not protect duplicated names between different loaders global scope */
820+ log_write ("metacall" , LOG_LEVEL_ERROR , "There are duplicated symbols already loaded in the global scope conflicting with handle: %s" , package_name );
821+ }
822+ else if (context_append (impl -> ctx , handle_impl -> ctx ) == 0 )
814823 {
815824 static const char func_init_name [] = LOADER_IMPL_FUNCTION_INIT ;
816825
0 commit comments