Skip to content
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
3 changes: 3 additions & 0 deletions regression-tests/pure2-trailing-comma-assert.cpp2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
main: () = {
assert(true, "some_potentially_long_string",);
}
24 changes: 24 additions & 0 deletions regression-tests/test-results/pure2-trailing-comma-assert.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

#define CPP2_IMPORT_STD Yes

//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"

#line 1 "pure2-trailing-comma-assert.cpp2"


//=== Cpp2 type definitions and function declarations ===========================

#line 1 "pure2-trailing-comma-assert.cpp2"
auto main() -> int;

//=== Cpp2 function definitions =================================================

#line 1 "pure2-trailing-comma-assert.cpp2"
auto main() -> int{
#line 2 "pure2-trailing-comma-assert.cpp2"
if (cpp2::cpp2_default.is_active() && !(true) ) { cpp2::cpp2_default.report_violation(CPP2_CONTRACT_MSG("some_potentially_long_string")); }
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pure2-trailing-comma-assert.cpp2... ok (all Cpp2, passes safety checks)

Empty file.
5 changes: 5 additions & 0 deletions source/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -8006,6 +8006,11 @@ class parser
}
}

// Consume trailing comma
if (curr().type() == lexeme::Comma) {
next();
}

if (curr().type() != lexeme::RightParen) {
error("expected ')' at the end of the contract");
return {};
Expand Down