lang: Add a resource-specific elvis operator
This allows you to omit a resource parameter programmatically, and avoids the need of an `undef` or `nil` in our language, which would contribute to programming errors, crashes, and overall reduced safety.
This commit is contained in:
@@ -122,6 +122,20 @@ func TestLexParse0(t *testing.T) {
|
||||
//exp: ???, // FIXME: add the expected AST
|
||||
})
|
||||
}
|
||||
{
|
||||
values = append(values, test{
|
||||
name: "one res with elvis",
|
||||
code: `
|
||||
test "t1" {
|
||||
int16 => true ?: 42, # elvis operator
|
||||
int32 => 42,
|
||||
stringptr => false ?: "", # missing is not ""
|
||||
}
|
||||
`,
|
||||
fail: false,
|
||||
//exp: ???, // FIXME: add the expected AST
|
||||
})
|
||||
}
|
||||
{
|
||||
// TODO: skip trailing comma requirement on one-liners
|
||||
values = append(values, test{
|
||||
|
||||
Reference in New Issue
Block a user