GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/m2

PR modula2/127567: Local module import cannot import external module

Fixes an issue where local module imports in Modula-2 could not access external libraries imported by the main module.

This change addresses a limitation in the Modula-2 compiler where a local module’s import statement could not refer to an external module if that module was only imported by the main program. The fix ensures that local imports can access external modules if they are available at the main module level, improving module usability.

In Details

Modula-2's module system has rules about import visibility. This commit adjusts the symbol table building process (specifically P1SymBuild.mod) to correctly handle imports within local modules when those imported modules are themselves external. It ensures PutImported is called for defimp or module symbols, and refines IsExternalModule and AddSymToModuleScope to prevent spurious errors related to external module imports.

For Context
Modula-2
A procedural programming language designed by Niklaus Wirth. It introduced concepts like modules for separate compilation and information hiding.
defimp
In Modula-2, a declaration that imports a module or specific definitions from a module.
module
A fundamental construct in Modula-2 for organizing code, enforcing encapsulation, and managing namespaces. Modules can define interfaces and implementations.
symbol table
A data structure used by a compiler to store information about identifiers (like variables, functions, types) encountered in source code. It's crucial for semantic analysis and code generation.
Filed Under: modula2compilermodules