tinyos / nesc

Master nesc repository
GNU General Public License v2.0
100 stars 53 forks source link

Typedef-d type in generic module parameters cannot be used as a type for other parameters inside the same parameter list #34

Open r0mi opened 9 years ago

r0mi commented 9 years ago

This module definition:

generic module ModuleM(typedef value_type @integer(), value_type value)

generates the following error for any integer type:

nesc1: cval.c:255: cval_uint_value: Assertion `0' failed.
nesC: Internal error.

in nesc 1.3.5

I believe this kind of module definition should be perfectly safe and sound and should not generate a compile error.

Sample code to reproduce the error: Custom interface:

interface Test<t>
{
    command bool test(t value);
}

Custom module that uses the interface:

generic module ModuleM(typedef value_type @integer(), value_type value)
{
    provides interface Test<value_type>;
}
implementation
{
    command bool Test.test(value_type val)
    {
        return val == value;
    }
}

Test application configuration:

configuration TestAppC{}
implementation {
    components TestC, MainC, new ModuleM(uint8_t, 42);
    MainC.Boot <- TestC;
    TestC.Test -> ModuleM;
}

Test application itself:

module TestC
{
    uses interface Test<uint8_t>;
    uses interface Boot;
}
implementation
{
    event void Boot.booted() {
        call Test.test(42);
    }
}