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:
James Shubin
2018-02-25 20:46:30 -05:00
parent 67607eba8b
commit 8e01b6db48
6 changed files with 130 additions and 10 deletions

View File

@@ -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{