mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Improve @param parse errors #1777
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
- Allow compile time `$foreach` iteration over constant Strings and bytes.
|
||||
- Improved error message when accessing `@private` from other modules #1769.
|
||||
- Include `@name` when searching for possible matches to `name` in the error message. #1779
|
||||
- Improve `@param` parse errors #1777
|
||||
|
||||
### Fixes
|
||||
- Fix case trying to initialize a `char[*]*` from a String.
|
||||
|
||||
@@ -2621,7 +2621,21 @@ static inline bool parse_contract_param(ParseContext *c, AstId *docs, AstId **do
|
||||
}
|
||||
else
|
||||
{
|
||||
try_consume(c, TOKEN_STRING);
|
||||
if (!try_consume(c, TOKEN_STRING))
|
||||
{
|
||||
if (!tok_is(c, TOKEN_DOCS_EOL) && !tok_is(c, TOKEN_DOCS_END))
|
||||
{
|
||||
if (tok_is(c, TOKEN_IDENT) || tok_is(c, TOKEN_TYPE_IDENT))
|
||||
{
|
||||
PRINT_ERROR_HERE("A string containing the parameter description was expected, did you forget enclosing the description in \"\" or ``?");
|
||||
}
|
||||
else
|
||||
{
|
||||
PRINT_ERROR_HERE("A string containing the description was expected after the parameter name.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
append_docs(docs_next, docs, ast);
|
||||
return true;
|
||||
|
||||
13
test/test_suite/functions/param_doc_error.c3
Normal file
13
test/test_suite/functions/param_doc_error.c3
Normal file
@@ -0,0 +1,13 @@
|
||||
<*
|
||||
@param some 1 *> // #error: parameter name
|
||||
|
||||
fn int foo(int some){
|
||||
return some + 1;
|
||||
}
|
||||
|
||||
<*
|
||||
@param some stuff *> // #error: did you forget enclosing the description in
|
||||
|
||||
fn int foo(int some){
|
||||
return some + 1;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
<*
|
||||
@hello
|
||||
@param feij > 0 // #error: Expected end of line
|
||||
@param feij > 0 // #error: A string containing the description
|
||||
*>
|
||||
|
||||
Reference in New Issue
Block a user