Skip to content

c_import: a header name that collides with an imported module's name is an error even when the program never uses it (raylib PI vs std.math PI; even use std.math.TAU) #1221

Closed

Description

@ehartford

Repro (a project with c.raylib):

use c_import("raylib.h")
use std.math.TAU        // or: use std.math

fn main:
    print(f"{TAU}")

Actual.

error: shadowing is not allowed for 'PI'
 --> <c_import raylib.h>:1087:1
1087 | let PI: f32 = 3.14159265358979323846

The program never mentions PI. The diagnostic points into a header the user did not write and cannot change. A selective import (use std.math.TAU) still collides, so it pulls the whole module's names into the check.

Expected. Two imports that both provide a name are not an error by themselves; only a use of the ambiguous name is, and that diagnostic names both providers and the spelling that picks one. A selective import introduces only the name it selects. (Mission: a collision nobody uses leaves no meaning undecided; an ambiguous use leaves two, and the programmer spells the choice there.)

Workaround used. The raylib spiral example uses raylib's own PI and imports nothing from std.math.

Activity

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