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

test expecting limits on generics #183

Open
hackedy opened this issue May 12, 2020 · 2 comments
Open

test expecting limits on generics #183

hackedy opened this issue May 12, 2020 · 2 comments

Comments

@hackedy
Copy link
Collaborator

hackedy commented May 12, 2020

This test examples/checker_tests/bad/issue2260-1.p4 is expecting that implicit casts aren't done on results of generic functions, or something like that. Our typechecker doesn't have any trouble with it, so I think it's fine.

@hackedy
Copy link
Collaborator Author

hackedy commented Feb 3, 2023

Here's what p4c says.

./issue2260-1.p4i(11): [--Werror=type-error] error: f
        bit<8> y = f(255);
                   ^^^^^^
  ---- Actual error:
  'int' type can only be unified with 'int', 'bit<>', or 'signed<>' types, not with '<returned type>'
  ---- Originating from:
  ./issue2260-1.p4i(6): Return type 'T' cannot be used for '<returned type>'
  T f<T>(T x) {
      ^
  Where 'T' is bound to 'int'
  ---- Originating from:
  ./issue2260-1.p4i(6): Function type 'f' does not match invocation type '<Method call>'
  T f<T>(T x) {
    ^
  ./issue2260-1.p4i(11)
          bit<8> y = f(255);
                     ^^^^^^

@pataei
Copy link
Collaborator

pataei commented Feb 3, 2023

Seems like p4c is doing the right thing. It's not accepting returning an arbitrary length int when f is invoked. On the other hand, Petr4 somehow isn't checking this. We need to look into what Petr4 is doing for method invocation with a generic type.

@pataei pataei self-assigned this Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants