0xMiden / 0xMiden/compiler

frontend(wasm): handle collisions of `export` and `global` names

Ouverte
#1,390 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
frontend ir wasm
Langage dominant
Rust
Étoiles
115
Forks
84
Merge moyen
1 j 8 h
PR mergées (30 j)
15

Description

Per Wasm spec the following is valid and contains `counter` as name of both a `global` and an exported function.

```wat
(module $counter_module
(global $counter (mut i32) (i32.const 0))
(func $read_counter (export "counter") (result i32)
global.get $counter))
```

For now such a collision between `global` and `export` name is rejected with a diagnostic (#1357), as we don't expect producers to generate it.

Some notes in case we want/need to support it later on:

- The `export` cannot be renamed. The `export` name must become the linkage name for external calls to resolve.
- So the (private) global must be renamed and in HIR the name of the global and references to it must be rewritten.
- The diagnostic is emitted in the wasm frontend in `fn resolve_func_symbols`.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

The diagnostic is emitted in the wasm frontend in `fn resolve_func_symbols`. Start by locating this function in the codebase. Understand how the current name resolution works for globals and exports. The fix involves renaming the private global and rewriting references in the HIR. Test with the provided WAT example to ensure the collision is handled correctly.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
rust, wasm
Domaine
compilers, frontend
Type d'issue
Fonctionnalité
Difficulté
3/5
Temps estimé
1-2 jours
Activité
Active
Clarté
Clairement spécifiée
Accessibilité débutants
65/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.