diff options
-rw-r--r-- | src/textual.cc | 8 | ||||
-rw-r--r-- | test/regress/1036.test | 80 |
2 files changed, 88 insertions, 0 deletions
diff --git a/src/textual.cc b/src/textual.cc index a1b17c14..8d4db512 100644 --- a/src/textual.cc +++ b/src/textual.cc @@ -1268,6 +1268,14 @@ bool instance_t::general_directive(char * line) if (*p == '@' || *p == '!') p++; + // Ensure there's an argument for all directives that need one. + if (! arg && + std::strcmp(p, "comment") != 0 && std::strcmp(p, "end") != 0 + && std::strcmp(p, "python") != 0 && std::strcmp(p, "test") != 0 && + *p != 'Y') { + throw_(parse_error, _f("Directive '%1%' requires an argument") % p); + } + switch (*p) { case 'a': if (std::strcmp(p, "account") == 0) { diff --git a/test/regress/1036.test b/test/regress/1036.test new file mode 100644 index 00000000..4e639e5b --- /dev/null +++ b/test/regress/1036.test @@ -0,0 +1,80 @@ + +account + +alias + +apply + +assert + +bucket + +check + +commodity + +def + +define + +apply account foo +end + +expr + +eval + +include + +!include + +import + +payee + +tag + +comment +foo bar +end comment + +value + +test source -> 17 +__ERROR__ +While parsing file "$FILE", line 2: +Error: Directive 'account' requires an argument +While parsing file "$FILE", line 4: +Error: Directive 'alias' requires an argument +While parsing file "$FILE", line 6: +Error: Directive 'apply' requires an argument +While parsing file "$FILE", line 8: +Error: Directive 'assert' requires an argument +While parsing file "$FILE", line 10: +Error: Directive 'bucket' requires an argument +While parsing file "$FILE", line 12: +Error: Directive 'check' requires an argument +While parsing file "$FILE", line 14: +Error: Directive 'commodity' requires an argument +While parsing file "$FILE", line 16: +Error: Directive 'def' requires an argument +While parsing file "$FILE", line 18: +Error: Directive 'define' requires an argument +While parsing file "$FILE", line 23: +Error: Directive 'expr' requires an argument +While parsing file "$FILE", line 25: +Error: Directive 'eval' requires an argument +While parsing file "$FILE", line 27: +Error: Directive 'include' requires an argument +While parsing file "$FILE", line 29: +Error: Directive 'include' requires an argument +While parsing file "$FILE", line 31: +Error: Directive 'import' requires an argument +While parsing file "$FILE", line 33: +Error: Directive 'payee' requires an argument +While parsing file "$FILE", line 35: +Error: Directive 'tag' requires an argument +While parsing file "$FILE", line 41: +Error: Directive 'value' requires an argument +end test + |