Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/webidl2.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
}

function const_value() {
return consume("true", "false", "null", "Infinity", "-Infinity", "NaN", FLOAT, INT);
return consume("true", "false", "Infinity", "-Infinity", "NaN", FLOAT, INT);
}

function const_data(token) {
Expand Down Expand Up @@ -721,7 +721,7 @@
if (!assign) {
return null;
}
const def = const_value() || consume(STR, "[") || error("No value for default");
const def = const_value() || consume(STR, "null", "[") || error("No value for default");
const expression = [def];
if (def.type === "[") {
const close = consume("]") || error("Default sequence value must be empty");
Expand Down Expand Up @@ -772,7 +772,6 @@
};
}
idlType = Object.assign({ type: "const-type" }, EMPTY_IDLTYPE, idlType);
type_suffix(idlType);
tokens.name = consume(ID) || error("No name for const");
tokens.assign = consume("=") || error("No value assignment for const");
tokens.value = const_value() || error("No value for const");
Expand Down
3 changes: 3 additions & 0 deletions test/invalid/baseline/const-null.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Syntax error at line 2, since `interface MyConstants`:
const MyPrimitive MY_NULL = null;
^ No value for const
3 changes: 3 additions & 0 deletions test/invalid/baseline/const-nullable.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Syntax error at line 3, since `interface MyConstants`:
const boolean? ARE_WE_THERE_YET = false;
^ No name for const
Comment thread
marcoscaceres marked this conversation as resolved.
Outdated
3 changes: 3 additions & 0 deletions test/invalid/idl/const-null.widl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
interface MyConstants {
const MyPrimitive MY_NULL = null;
};
4 changes: 4 additions & 0 deletions test/invalid/idl/const-nullable.widl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06
interface MyConstants {
const boolean? ARE_WE_THERE_YET = false;
};
86 changes: 1 addition & 85 deletions test/syntax/baseline/nullable.json
Original file line number Diff line number Diff line change
@@ -1,88 +1,4 @@
[
{
"type": "interface",
"name": "MyConstants",
"escapedName": "MyConstants",
"inheritance": null,
"members": [
{
"type": "const",
"name": "ARE_WE_THERE_YET",
"idlType": {
"type": "const-type",
"generic": null,
"nullable": {
"trivia": ""
},
"union": false,
"idlType": "boolean",
"baseName": "boolean",
"escapedBaseName": "boolean",
"prefix": null,
"postfix": null,
"separator": null,
"extAttrs": null,
"trivia": {
"base": " "
}
},
"extAttrs": null,
"value": {
"type": "boolean",
"value": false
},
"trivia": {
"base": "\n ",
"name": " ",
"assign": " ",
"value": " ",
"termination": ""
}
},
{
"type": "const",
"name": "MY_NULL",
"idlType": {
"type": "const-type",
"generic": null,
"nullable": {
"trivia": ""
},
"union": false,
"idlType": "MyPrimitive",
"baseName": "MyPrimitive",
"escapedBaseName": "MyPrimitive",
"prefix": null,
"postfix": null,
"separator": null,
"extAttrs": null,
"trivia": {
"base": " "
}
},
"extAttrs": null,
"value": {
"type": "null"
},
"trivia": {
"base": "\n ",
"name": " ",
"assign": " ",
"value": " ",
"termination": ""
}
}
],
"extAttrs": null,
"partial": null,
"trivia": {
"base": "// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06\n",
"name": " ",
"open": " ",
"close": "\n",
"termination": ""
}
},
{
"type": "interface",
"name": "Node",
Expand Down Expand Up @@ -126,7 +42,7 @@
"extAttrs": null,
"partial": null,
"trivia": {
"base": "\n\n",
"base": "",
"name": " ",
"open": " ",
"close": "\n // ...\n",
Expand Down
6 changes: 0 additions & 6 deletions test/syntax/idl/nullable.widl
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06
interface MyConstants {
const boolean? ARE_WE_THERE_YET = false;
const MyPrimitive? MY_NULL = null;
};

interface Node {
readonly attribute DOMString? namespaceURI;
// ...
Expand Down