Skip to content

fix(docs): add missing type definitions in impl alias example#9499

Open
forkfury wants to merge 3 commits intostarkware-libs:mainfrom
forkfury:fix/aliases-impl-example-context
Open

fix(docs): add missing type definitions in impl alias example#9499
forkfury wants to merge 3 commits intostarkware-libs:mainfrom
forkfury:fix/aliases-impl-example-context

Conversation

@forkfury
Copy link
Contributor

Summary

Fixed incomplete impl alias example in aliases.adoc by adding missing trait and impl definitions. The example previously referenced undefined types (Pow, Algebra, I32Algebra), making it confusing for readers who couldn't understand the code without external context.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

⚠️ Note:
To keep maintainer workload sustainable, we generally do not accept PRs that
are only minor wording, grammar, formatting, or style changes.
Such PRs may be closed without detailed review.


Why is this change needed?

The impl alias example in aliases.adoc was incomplete and misleading. It showed an impl alias referencing AnyAlgebraPow<i32, I32Algebra>, but neither the Pow trait, Algebra trait, nor I32Algebra impl were defined in the example. This made the code snippet non-functional and confusing for readers trying to understand impl aliases, as they couldn't see how the types relate or what the example actually demonstrates.


What was the behavior or documentation before?

The example showed:airo
// Pow implementation for any algebra.
impl AnyAlgebraPow<A, impl AlgImpl: Algebra> of Pow { ... }

// Impl alias for Pow of i32.
impl Int32Pow = AnyAlgebraPow<i32, I32Algebra>;This referenced undefined types (Pow, Algebra, I32Algebra) and used placeholder syntax ({ ... }), making it impossible to understand without looking up other documentation files.


What is the behavior or documentation after?

The example now includes complete, self-contained definitions:o
trait Pow {
fn pow(base: T, exp: u32) -> T;
}

impl AnyAlgebraPow<T, impl AlgImpl: Algebra> of Pow {
fn pow(base: T, exp: u32) -> T {
// Implementation details.
base
}
}

trait Algebra {
fn identity() -> T;
}

impl I32Algebra of Algebra {
fn identity() -> i32 {
1
}
}

// Impl alias for Pow of i32.
impl Int32Pow = AnyAlgebraPow<i32, I32Algebra>;Readers can now understand the complete relationship between traits, impls, and impl aliases without needing to reference other documentation.


Related issue or discussion (if any)


Additional context

This aligns the example with the approach used in impl-aliases.adoc, which provides complete, self-contained examples. The fix ensures consistency across documentation and improves the learning experience for developers new to Cairo's impl alias feature.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orizi made 1 comment.
Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @forkfury).


docs/reference/src/components/cairo/modules/language_constructs/pages/aliases.adoc line 30 at r1 (raw file):

Examples:
[source,cairo]
----

this entire section should just point to the impl-aliases page and not exist at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants