Skip to content

No clear way to create a new global import #226

@PinkCherryBlossom

Description

@PinkCherryBlossom

Summary

The only way I can see to add the global part of a global import is ModuleGlobals::add_import. This requires an ImportId for the import part of the global import. The only way I can see to get that is by using ModuleImports::add, but that requires an ImportKind enum, which for the global variant requires... a GlobalId, which we need to call ModuleGlobals::add_import to get... and we're back where we started.

Additional Details

Perhaps one potential way to do this would be to call ModuleGlobals::add_local with dummy values to reserve a GlobalId, then mutate that later? But that feels like quite an ugly workaround.

Am I missing some easy way of doing this? If not, should there perhaps be a utility function that can allocate to both arenas at once so this is possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions