Skip to content

Possible to "silently" import module twice. #7824

@tdavidovicNV

Description

@tdavidovicNV

I have a module materials implemented in 3 files:

materials.slang

module materials;
__include types;
__include material_instance;

types.slang

implementing materials;
public struct ShadingData : IDifferentiable
{
    float3 P_ws = {};
}

material_instance.slang

implementing materials;
public interface IMaterialInstance
{
    public float3 eval<S : ISampleGenerator>(
        const ShadingData sd,
        const float3 wo_ws,
        inout S sg
    );
}

In another module, I accidentally wrote this:

import materials;
import material_instance;

ShadingData sd;

and Slang Language Server (at least, haven't actually compiled that particular usecase) complains about ShadingData having double definition.

I assume that import brings the materials module in twice, because it checks duplicity against the import filename, and not the implementing keyword inside. This results in a confusing error.

I'd probably just forbid importing files that contain implementing, rather than try to handling the module (de)duplication.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions