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

Error message for checking of types inside header does not say what the specialization is location is #3170

Closed
apinski-cavium opened this issue Apr 4, 2022 · 7 comments · Fixed by #3174
Assignees
Labels
enhancement This topic discusses an improvement to existing compiler code. fixed This topic is considered to be fixed.

Comments

@apinski-cavium
Copy link

Take:

header yy
{
  bit tt;
}
struct y
{
  yy[2] tt;
}
header t<tt>
{
  tt y;
}

typedef t ty;
typedef ty<y> tty;

Right now the compiler outputs:

t2.p4(11): [--Werror=type-error] error: Field 'y' of 'header t' cannot have type 'struct y'
  tt y;
     ^
t2.p4(5)
struct y
       ^

But it does not reference the last typedef line for the subsitution that had happened so it is not obvious where the problem is located.
I suspect this is an issue with most places of subsitutions too include functions.

@apinski-cavium
Copy link
Author

Another issue is it does not tell you why this struct cannot be part of the header, it is the header stack that is the issue.

@mihaibudiu mihaibudiu self-assigned this Apr 4, 2022
@mihaibudiu
Copy link
Contributor

I would ask a different question: should this be even legal: typedef t ty.
I am tempted to resolve the problem you point out by saying "no", when you typedef you cannot partially specialize a type; if you use a generic type you must supply type arguments.

@mihaibudiu mihaibudiu added bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed. labels Apr 4, 2022
@mihaibudiu
Copy link
Contributor

@apinski-cavium not sure that this is a true solution to the problem you are raising.

@apinski-cavium
Copy link
Author

That is a different issue really.
You can see the issue still with:

header yy
{
  bit tt;
}
struct y
{
  yy[2] tt;
}
header t<tt>
{
  tt y;
}

typedef t<y> tty;

Which gives:

t2.p4(11): [--Werror=type-error] error: Field 'y' of 'header t' cannot have type 'struct y'
  tt y;
     ^
t2.p4(5)
struct y
       ^

No where is the line for the typedef is referenced.

@mihaibudiu
Copy link
Contributor

Reopening for the last example.

@mihaibudiu mihaibudiu added enhancement This topic discusses an improvement to existing compiler code. fixed This topic is considered to be fixed. and removed bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed. labels Apr 6, 2022
@mihaibudiu
Copy link
Contributor

@apinski-cavium how does the solution in #3182 look like?

@apinski-cavium
Copy link
Author

@apinski-cavium how does the solution in #3182 look like?

Looks good (just looked at the testcase to see how it would look).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This topic discusses an improvement to existing compiler code. fixed This topic is considered to be fixed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants