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

[Feature] Tentative struct definition for type parameter declaration #598

Open
taichi-ishitani opened this issue Mar 26, 2024 · 0 comments
Labels
lang Language design

Comments

@taichi-ishitani
Copy link
Contributor

I'm rewriting a SV module having type parameter assumed to be overwritten by struct type.
I put logic to this kind of parameter as tentative type.
https://github.com/pezy-computing/pzbcm/blob/8f796eb5e83ce8fbadbbc93aea1012f680fadd3f/pzbcm_min_max_finder/pzbcm_min_max_finder.sv#L11

During building Veryl version of this module I got following errors because default value of RESULT is logic and logic does not have data and location members.

[INFO ]   Processing file (/home/ishitani/workspace/pzbcm_veryl/pzbcm_min_max_finder/pzbcm_min_max_finder.veryl)
Error:   × veryl check failed

Error: unknown_member (https://doc.veryl-lang.org/book/06_appendix/02_semantic_error.html#unknown_member)

  × "result" doesn't have member "data"
    ╭─[/home/ishitani/workspace/pzbcm_veryl/pzbcm_min_max_finder/pzbcm_min_max_finder.veryl:63:1]
 63 │     if next_n == 1 {
 64 │       result.data     = next_data[0];
    ·       ───┬──
    ·          ╰── Error location
 65 │       result.location = next_location;
    ╰────
  help:
Error: unknown_member (https://doc.veryl-lang.org/book/06_appendix/02_semantic_error.html#unknown_member)

  × "result" doesn't have member "location"
    ╭─[/home/ishitani/workspace/pzbcm_veryl/pzbcm_min_max_finder/pzbcm_min_max_finder.veryl:64:1]
 64 │       result.data     = next_data[0];
 65 │       result.location = next_location;
    ·       ───┬──
    ·          ╰── Error location
 66 │     } else {
    ╰────
  help:

To resolve this kind of problem, I'd like Veryl to have a notation to describe required members for a param type declaration like below.

param RESULT: type = struct(data, location)
@dalance dalance added the lang Language design label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang Language design
Projects
None yet
Development

No branches or pull requests

2 participants