cgen error with -cstrict -cc clang
, and source code with a defer body in a match branch, using a local var declared in the match branch
#19092
Labels
Bug
This tag is applied to issues which reports bugs.
Unit: cgen
Bugs/feature requests, that are related to the default C generating backend.
Unit: Checker
Bugs/feature requests, that are related to the type checker.
Unit: Compiler
Bugs/feature requests, that are related to the V compiler in general.
V doctor:
What did you do?
v -g -o vdbg cmd/v && vdbg defer_in_match.v
What did you expect to see?
A checker error, telling me that the second defer is not allowed, since it uses variables that are only available inside the match branch, and will not be available or properly initialised outside that match
Alternatively, cgen should have generated not just
bool old;
butbool old = false;
, so that compilation with-cstrict -cc clang
will pass (V's defer implementation ensures that it will not be used, but the C compiler does not know that).What did you see instead?
Without -cstrict:
With
-cstring -cc clang
:The text was updated successfully, but these errors were encountered: