Skip to content

A module's own extern fn is rejected as "requires an explicit import" once another module imports std.libc #1919

Closed

Description

@ehartford

Spec: §18.1 (imports), D70 (last explicit import wins). A name a module declares itself (here an extern fn) is that module's; importing std.libc elsewhere in the program must not make it unresolvable.

Repro (installed with, 2026-09-29):

helper.w

extern fn unlink(path: *const u8) -> i32

pub fn remove_it(p: *const u8) -> i32:
    unsafe { unlink(p) }

main.w

use helper
use std.libc

fn main:
    print(f"{remove_it(c"/nonexistent/x".ptr)}")

with check main.w:

error: 'unlink' requires an explicit import (§18.1); add: use std.libc.unlink
 --> helper.w:4:14

Expected: ok — helper.w's own declaration resolves unlink.

Found in #1915 (macOS slice): the compiler cannot use std.zip (which imports std.libc), because src/compiler/ClangBridge.w declares its own extern fn unlink. Workaround used: with get still unpacks .zip source archives with the host's tar, with a printed warning; the fix lets ConanClient use std.zip and drop that.

Activity

  1. ehartford commented on Sep 30, 2026

    @ehartford
    ContributorAuthor

    Fixed on main in 8b6b850 (#1926): frontend_fn_tier_verdict no longer drops a module's own extern fn when a standard-library fn of the same name exists elsewhere; behav_1919_extern_beside_std_fn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions