Skip to content

fix(codegen): remove two unused-variable warnings#1600

Merged
SchoolyB merged 2 commits intoSchoolyB:devfrom
mvanhorn:osc/1597-unused-vars
May 1, 2026
Merged

fix(codegen): remove two unused-variable warnings#1600
SchoolyB merged 2 commits intoSchoolyB:devfrom
mvanhorn:osc/1597-unused-vars

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

@mvanhorn mvanhorn commented May 1, 2026

Summary

Removes two -Wunused-variable warnings from ezc/src/codegen/codegen.c by deleting two leftover declarations that were assigned but never read. After the change, make build compiles with zero warnings.

Why this matters

Issue #1597 reports both warnings explicitly with line numbers. Reproducing on main (commit 5cd0dba):

src/codegen/codegen.c:6282:9: warning: unused variable 'if_depth' [-Wunused-variable]
src/codegen/codegen.c:7365:25: warning: unused variable 'ct' [-Wunused-variable]

The issue's "Fix" section asks first whether each variable was meant to be used downstream and to remove only if it was a leftover.

For if_depth: a grep across the whole file shows the name appears once (the assignment itself) and nowhere else. Nothing reads it. The surrounding block manages cg->loop_scope_depth directly with cg->loop_scope_depth++, so the temporary copy is not part of any unfinished scope-restore logic.

For ct at line 7365: there are two const char *ct = ez_type_to_c_cg(...) declarations in the file. The one at line 6085 is read on the very next line (emitf(cg, "{ %s %s = ", ct, src_var);) and is not the one the warning points to. The warning is about the second one, inside the for (int j = 0; j < fc; j++) loop that builds ez_json_parse_<struct>. The loop body emits via emitf with literal C type names ("EzString", ez_builtin_string_to_int, etc.) and never references ct. So this ct is also a leftover from work that ended up taking a different code path.

Both deletions are safe.

Changes

ezc/src/codegen/codegen.c: deletes int if_depth = cg->loop_scope_depth; (was line 6282) and const char *ct = ez_type_to_c_cg(cg, f->type_name); (was line 7365). Net: 2 lines removed, 0 added.

Testing

$ make build 2>&1 | grep -E "warning:|error:"
(no output)

make build runs clean on the change. The pre-existing ct declaration at line 6085 (which is used) is left alone.

Closes #1597

@SchoolyB SchoolyB added the PR: In Review This PR is being reviewed label May 1, 2026
@SchoolyB SchoolyB changed the base branch from main to dev May 1, 2026 13:41
Copy link
Copy Markdown
Owner

@SchoolyB SchoolyB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mvanhorn! So cool that you came across EZ! Thank you for contributing 👍🏾 LGTM 🚀

@SchoolyB SchoolyB added PR: Ready This PR is ready pull request is ready to merge and removed PR: In Review This PR is being reviewed labels May 1, 2026
@SchoolyB SchoolyB merged commit 121647d into SchoolyB:dev May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Ready This PR is ready pull request is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: two unused variable warnings in codegen.c

2 participants