diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 137a4439a..606e858c6 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -298,6 +298,8 @@ boost::optional checkOptimizerKeys(Json::Value const& _input) boost::optional checkMetadataKeys(Json::Value const& _input) { + if (_input.isObject() && _input.isMember("useLiteralContent") && !_input["useLiteralContent"].isBool()) + return formatFatalError("JSONError", "\"settings.metadata.useLiteralContent\" must be Boolean"); static set keys{"useLiteralContent"}; return checkKeys(_input, keys, "settings.metadata"); } diff --git a/test/cmdlineTests/standard_missing_key_useLiteralContent/exit b/test/cmdlineTests/standard_missing_key_useLiteralContent/exit new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/test/cmdlineTests/standard_missing_key_useLiteralContent/exit @@ -0,0 +1 @@ +0 diff --git a/test/cmdlineTests/standard_missing_key_useLiteralContent/input.json b/test/cmdlineTests/standard_missing_key_useLiteralContent/input.json new file mode 100644 index 000000000..8627a282a --- /dev/null +++ b/test/cmdlineTests/standard_missing_key_useLiteralContent/input.json @@ -0,0 +1,19 @@ +{ + "language": "Solidity", + "sources": + { + "A": + { + "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + } + }, + "settings": + { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "byzantium", + "metadata": {} + } +} diff --git a/test/cmdlineTests/standard_missing_key_useLiteralContent/output.json b/test/cmdlineTests/standard_missing_key_useLiteralContent/output.json new file mode 100644 index 000000000..14c325725 --- /dev/null +++ b/test/cmdlineTests/standard_missing_key_useLiteralContent/output.json @@ -0,0 +1 @@ +{"sources":{"A":{"id":0}}} \ No newline at end of file diff --git a/test/cmdlineTests/standard_wrong_type_useLiteralContent/exit b/test/cmdlineTests/standard_wrong_type_useLiteralContent/exit new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/test/cmdlineTests/standard_wrong_type_useLiteralContent/exit @@ -0,0 +1 @@ +0 diff --git a/test/cmdlineTests/standard_wrong_type_useLiteralContent/input.json b/test/cmdlineTests/standard_wrong_type_useLiteralContent/input.json new file mode 100644 index 000000000..be4272b6c --- /dev/null +++ b/test/cmdlineTests/standard_wrong_type_useLiteralContent/input.json @@ -0,0 +1,21 @@ +{ + "language": "Solidity", + "sources": + { + "A": + { + "content": "pragma solidity >=0.0; contract C { function f() public pure {} }" + } + }, + "settings": + { + "optimizer": { + "enabled": true, + "runs": 200 + }, + "evmVersion": "byzantium", + "metadata": { + "useLiteralContent": "literalContent" + } + } +} diff --git a/test/cmdlineTests/standard_wrong_type_useLiteralContent/output.json b/test/cmdlineTests/standard_wrong_type_useLiteralContent/output.json new file mode 100644 index 000000000..47eb32ec4 --- /dev/null +++ b/test/cmdlineTests/standard_wrong_type_useLiteralContent/output.json @@ -0,0 +1 @@ +{"errors":[{"component":"general","formattedMessage":"\"settings.metadata.useLiteralContent\" must be Boolean","message":"\"settings.metadata.useLiteralContent\" must be Boolean","severity":"error","type":"JSONError"}]}