feat(C3.1): #foreign refs are validated — must name a #library or a named #import c unit
validateForeignRefs walks the merged tree (libraries + named c units, nested namespaces included) and diagnoses any #foreign whose ref names neither — a typo'd ref previously compiled and resolved silently through whatever image carried the symbol. Decls synthesized from #include headers carry no ref and are exempt. Flips the C0.2b pin; zero collateral across the 608 other examples.
This commit is contained in:
@@ -298,6 +298,13 @@ pub const Compilation = struct {
|
||||
/// Lower the parsed AST to the sx IR module (shadow pipeline).
|
||||
pub fn lowerToIR(self: *Compilation) !ir.Module {
|
||||
const root = self.resolved_root orelse self.root orelse return ir.Module.init(self.allocator);
|
||||
|
||||
// Every `#foreign <ref>` must name a #library constant or a named
|
||||
// `#import c` unit — a typo'd ref otherwise resolves silently
|
||||
// through whatever image happens to carry the symbol.
|
||||
try c_import.validateForeignRefs(self.allocator, root, &self.diagnostics);
|
||||
if (self.diagnostics.hasErrors()) return error.CompileError;
|
||||
|
||||
var module = ir.Module.init(self.allocator);
|
||||
//TODO: find a better place for this
|
||||
if (self.target_config.isWasm32()) {
|
||||
|
||||
Reference in New Issue
Block a user