wavefnd / wavefnd/Wave

Support generic struct and proto methods through monomorphization

Open
#435 0 comments 0 reactions 0 assignees View on GitHub
enhancement feature request help wanted needs testing
Dominant language
Rust
Stars
53
Forks
16
Avg merge
4h 22m
Merged PRs (30d)
46

Description

## Summary

The generic rewriting pass currently rejects methods with generic parameters inside structs and proto implementations. This leaves an intentional frontend gap even when the surrounding type can already be monomorphized.

## Related issue

- #348

## Relevant code

- `front/parser/src/generics.rs`
- generic environment and call-site resolution
- typed HIR validation

## Scope

Define and implement generic method instantiation for struct methods and proto implementation methods. Method-level type parameters must coexist predictably with receiver or enclosing-type parameters.

## Acceptance criteria

- Generic struct methods can be declared and called.
- Generic proto implementation methods follow the same substitution rules.
- Enclosing and method-level type parameters cannot collide silently.
- Call-site inference and explicit generic arguments have documented behavior.
- Equivalent instantiations are deduplicated.
- Recursive or cyclic instantiation produces a diagnostic instead of unbounded rewriting.
- Typed HIR retains fully resolved method signatures.
- Positive and negative frontend fixtures cover nested generic types, ambiguity, and constraint failures.

Contributor guide

Open the contributing guide

Research direction

Start in front/parser/src/generics.rs, then trace the generic environment, call-site resolution, and typed HIR validation paths. Map how enclosing and method-level parameters are substituted for struct and proto implementation methods. Done means declarations and calls work, signatures remain resolved, equivalent instantiations are deduplicated, cycles diagnose cleanly, and frontend fixtures cover the listed failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.