quint icon indicating copy to clipboard operation
quint copied to clipboard

Trailing comma in const initialization

Open p-offtermatt opened this issue 11 months ago • 2 comments

Hi,

take this example:

module a {
    const A: int
    const B: int    
}

module b {
    import a(
        A = 5,
        B = 5
    ).* 
}

Here, everything works fine. When I add this trailing comma, I get an error:

module a {
    const A: int
    const B: int    
}

module b {
    import a(
        A = 5,
        B = 5,
    ).* 
}

the error is:

no viable alternative at input 'importa(A=5,B=5,)'quint(QNT000)

This is also the case in function calls (the error is different, however):

module a {
    pure def f(
        a: int,
        b: int,
    ): int = a + b
}

gives me

mismatched input ')' expecting {'_', LOW_ID, CAP_ID}quint(QNT000)

However, trailing commas work fine in record definitions:

module a {
    type A = {
        a: string,
        b: int,
    }
}

I feel like the right behaviour is to allow trailing commas in all of these cases.

p-offtermatt avatar Feb 29 '24 14:02 p-offtermatt

Makes sense to me.

shonfeder avatar Feb 29 '24 17:02 shonfeder

I believe it is quite common for trailing commas to be disallowed inside things with parenthesis, but allowed elsewhere. I don't like this tho, we should allow it everywhere.

bugarela avatar Mar 11 '24 14:03 bugarela