diff --git a/src/packcc.c b/src/packcc.c index 2a840bf..72873ae 100644 --- a/src/packcc.c +++ b/src/packcc.c @@ -128,7 +128,7 @@ DECLSPEC_IMPORT HRESULT WINAPI SHGetFolderPathA(HWND hwnd, int csidl, HANDLE hTo #define WEBSITE "https://github.com/arithy/packcc" -#define VERSION "2.0.2" +#define VERSION "2.0.3" #ifndef BUFFER_MIN_SIZE #define BUFFER_MIN_SIZE 256 @@ -3145,7 +3145,8 @@ static bool_t parse(context_t *ctx) { link_references(ctx, rule->expr); } } - mark_rules_if_used(ctx, ctx->rules.buf[0]); + if (ctx->rules.len > 0) + mark_rules_if_used(ctx, ctx->rules.buf[0]); { size_t i; for (i = 0; i < ctx->rules.len; i++) { diff --git a/tests/issue_78.d/input.peg b/tests/issue_78.d/input.peg new file mode 100644 index 0000000..60dad1a --- /dev/null +++ b/tests/issue_78.d/input.peg @@ -0,0 +1 @@ +main <- ( "A" diff --git a/tests/issue_78.d/issue_78.bats b/tests/issue_78.d/issue_78.bats new file mode 100644 index 0000000..bb0b47a --- /dev/null +++ b/tests/issue_78.d/issue_78.bats @@ -0,0 +1,9 @@ +#!/usr/bin/env bats + +load "$TESTDIR/utils.sh" + +@test "Testing issue_78.d - generation" { + run test_generate + [ "$status" -eq 10 ] + [[ "$output" =~ ': input.peg:1:1: Illegal rule syntax'$ ]] +}