Skip to content

proc-scoped type aliases cannot be used with zero! #1359

@rw1nkler

Description

@rw1nkler

Describe the bug

9117692 introduced a syntax for defining convenient proc scoped aliases.
However, when proc scoped aliases are used with zero! macro, the type cannot be resolved correctly.

To Reproduce

One can spot a problem by modifying the init function of the test proc from proc_with_alias.x in the following way:

proc P {
    type MyU32 = u32;
    s: chan<MyU32> out;

    config(s: chan<MyU32> out) { (s,) }

    init {
        type AnotherU32 = u32;

        //zero!<AnotherU32>() // this works correctly
        zero!<MyU32>() // this causes problems
    }

    next(tok: token, state: MyU32) {
        send(tok, s, state);
        let new_state = state + MyU32:1;
        new_state
    }
}

To run the test after modifications use:

bazel test //xls/dslx/tests:proc_with_alias_dslx_test

Here is the error message, that shows a problem with parsing the proc:

ERROR: /home/rwinkler/projects/xls/xls/dslx/tests/BUILD:1145:15: Parsing and type checking DSLX source files of target proc_with_alias_dslx failed: (Exit 255): bash failed: error executing command (from target //xls/dslx/tests:proc_with_alias_dslx) /bin/bash -c ... (remaining 1 argument skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
xls/dslx/tests/proc_with_alias.x:25:15-25:20
0023:
0024:         //zero!<AnotherU32>() // this works correctly
0025:         zero!<MyU32>() // this causes problems
~~~~~~~~~~~~~~~~~~~~^---^ TypeMissingError: node: 0x5571295ea090 user: 0x5571295f7d10 internal error: AST node is missing a corresponding type: MyU32 0x5571295ea090 (kind: NameDef) defined @ xls/dslx/tests/proc_with_alias.x:16:10-16:15. This may be due to recursion, which is not supported.
0026:     }
0027:
Error parsing and type checking DSLX source file: xls/dslx/tests/proc_with_alias.x
Target //xls/dslx/tests:proc_with_alias_dslx_test failed to build

Expected behavior

zero! should be able to use proc scoped type aliases, and the snipped from the previous section should be parsed correctly.

Additional context

Related issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working or is incorrectdslxDSLX (domain specific language) implementation / front-end

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions