Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D: parse contract expressions #3708

Merged
merged 1 commit into from
May 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions Units/parser-d.r/simple.d.d/expected.tags
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ main input.d /^void main(string[] args)$/;" f file:
member input.d /^ T member;$/;" m class:Class.CT file:
modulevar input.d /^ int modulevar;$/;" m file:
obj input.d /^Object obj;$/;" v
out_contract input.d /^void out_contract()$/;" f file:
qar input.d /^ int qar;$/;" m union:Struct.Union file:
quxx input.d /^ bool quxx;$/;" m union:Struct.Union file:
test.simple input.d /^module test.simple;$/;" M
Expand Down
4 changes: 4 additions & 0 deletions Units/parser-d.r/simple.d.d/input.d
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ static assert( num < TL.length, "Name '"~name~"' is not found");

__gshared int globalVar;

void out_contract()
out(r; r > 0) {}

void main(string[] args)
in(args.length > 0)
{
auto foo = new Class(1337);

Expand Down
8 changes: 7 additions & 1 deletion parsers/c-based.c
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,13 @@ static bool skipPostArgumentStuff (
{
case KEYWORD_ATTRIBUTE: skipParens (); break;
case KEYWORD_THROW: skipParens (); break;
case KEYWORD_IF: if (isInputLanguage (Lang_d)) skipParens (); break;
case KEYWORD_IF: // D template constraint
// D contract expressions
case KEYWORD_IN:
case KEYWORD_OUT:
if (isInputLanguage (Lang_d))
skipParens ();
break;
case KEYWORD_TRY: break;

case KEYWORD_CONST:
Expand Down