Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow use custom's const field to declare symbolic size #195

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

katat
Copy link
Collaborator

@katat katat commented Sep 26, 2024

This makes it able to declare methods to return array using the struct's field as its symbolic size.

For example:

fn Thing.to_array(self) -> [Field; self.cst] {
    return [1; self.cst];
}

Changes

  1. Refactored the constant propagation to allow propagating multiple constants, such as array and custom type, in addition to single constant.
  2. Allow propagating constant values from native function/method.

I also create an issue to propose supporting const attribute for custom fields for better type checking. So it can type check self.cst for [Field; self.cst] where the symbolic size has to be constant.

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.

1 participant