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

Int as parameter and assignments #2357

Closed
fruffy opened this issue May 4, 2020 · 2 comments
Closed

Int as parameter and assignments #2357

fruffy opened this issue May 4, 2020 · 2 comments
Assignees
Labels
bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed.

Comments

@fruffy
Copy link
Collaborator

fruffy commented May 4, 2020

This comes back to the question in #2354. Are these sorts of parameters allowed?

bit<8> do_function1(in int val1) {
    return 8w1;
}

bit<8> do_function2(inout bit<8> val0, in int val1) {
    val0 = val1;
    return 8w1;
}

control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {

    apply {
        bit<8> tmp = 8w1;
        do_function1(1);
        do_function2(tmp, 1);
    }
}

In this case, I get an error which says:

...
InlineActions_3_RemoveAllUnusedDeclarations
FrontEnd_44_InlineActions
P4::TypeChecking_0_ResolveReferences
P4::TypeChecking_1_TypeInference
InlineFunctions_0_TypeChecking
InlineFunctions_1_DiscoverFunctionsInlining
InlineFunctions_2_InlineDriver
PassRepeated_0_ResolveReferences
PassRepeated_1_RemoveUnusedDeclarations
PassRepeated_2_ResolveReferences
PassRepeated_3_RemoveUnusedDeclarations
RemoveAllUnusedDeclarations_0_PassRepeated
InlineFunctions_3_RemoveAllUnusedDeclarations
P4::TypeChecking_2_ResolveReferences
[--Werror=type-error] error: val1_1: Cannot declare variables with type int

Which also does not seem correct, maybe caused by the latest changes. Should declaration be a Declaration_Constant?

int_function_arguments.p4.txt

@mihaibudiu
Copy link
Contributor

This should be fixed by #2360, but it's not easy to check since this is not a full program.

@mihaibudiu mihaibudiu added bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed. labels May 4, 2020
@mihaibudiu mihaibudiu self-assigned this May 4, 2020
@fruffy
Copy link
Collaborator Author

fruffy commented May 4, 2020

Forgot the attachment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed.
Projects
None yet
Development

No branches or pull requests

2 participants