Skip to content

Implement struct parameter modifiers (in[], mut[], out[]) #419

@antonsynd

Description

@antonsynd

Context

Identified during spec-test alignment audit (GAP-16). The language specification documents struct parameter modifiers but they are not implemented in the compiler.

Current behavior

Struct parameter modifiers (in[], mut[], out[]) are documented in the specification but are not recognized by the lexer, parser, or semantic analysis. Using them results in a syntax error.

Expected/proposed

Implement the struct parameter modifier syntax as specified:

  • in[T] — immutable borrow (pass by readonly reference)
  • mut[T] — mutable borrow (pass by reference)
  • out[T] — output parameter

These modifiers provide explicit control over struct passing semantics, aligning with the .NET value type model while maintaining Python-like syntax.

Implementation would require changes to:

  1. Lexer — recognize in, mut, out as contextual keywords in parameter positions
  2. Parser — parse modifier syntax in parameter declarations
  3. Semantic — validate modifier usage (e.g., mut only on struct types)
  4. CodeGen — emit appropriate ref/in/out parameter modifiers in C#

References

  • docs/language_specification/structs.md — struct parameter modifier specification
  • docs/language_specification/type_system.md — value type semantics

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions