diff --git a/lib/productions/argument.js b/lib/productions/argument.js index 5292bb2b..f77d4735 100644 --- a/lib/productions/argument.js +++ b/lib/productions/argument.js @@ -50,6 +50,10 @@ export class Argument extends Base { const message = `Optional dictionary arguments must have a default value of \`{}\`.`; yield validationError(this.source, this.tokens.name, this, message); } + if (this.idlType.nullable) { + const message = `Dictionary arguments cannot be nullable.`; + yield validationError(this.source, this.tokens.name, this, message); + } } } } diff --git a/test/invalid/baseline/argument-dict-nullable.txt b/test/invalid/baseline/argument-dict-nullable.txt new file mode 100644 index 00000000..0d0bcef9 --- /dev/null +++ b/test/invalid/baseline/argument-dict-nullable.txt @@ -0,0 +1,12 @@ +Validation error at line 13 in argument-dict-nullable.webidl, inside `argument dict`: + x2(optional Dict? dict = {}) + ^ Dictionary arguments cannot be nullable. +Validation error at line 14 in argument-dict-nullable.webidl, inside `argument union`: +boolean or Dict)? union = {}) + ^ Dictionary arguments cannot be nullable. +Validation error at line 15 in argument-dict-nullable.webidl, inside `argument union`: + z2(optional Union? union = {}) + ^ Dictionary arguments cannot be nullable. +Validation error at line 16 in argument-dict-nullable.webidl, inside `argument req`: + void r(Required? req); + ^ Dictionary arguments cannot be nullable. diff --git a/test/invalid/idl/argument-dict-nullable.webidl b/test/invalid/idl/argument-dict-nullable.webidl new file mode 100644 index 00000000..0443fd21 --- /dev/null +++ b/test/invalid/idl/argument-dict-nullable.webidl @@ -0,0 +1,17 @@ +dictionary Dict { + short x = 0; +}; + +dictionary Required { + required short x; +}; + +typedef (short or Dict) Union; + +[Exposed=Window] +interface X { + void x2(optional Dict? dict = {}); + void y2(optional (boolean or Dict)? union = {}); + void z2(optional Union? union = {}); + void r(Required? req); +};