Skip to content

resolve MSVC warning (#321)#322

Merged
pantor merged 3 commits intopantor:mainfrom
ArmaanCPro:main
Jan 9, 2026
Merged

resolve MSVC warning (#321)#322
pantor merged 3 commits intopantor:mainfrom
ArmaanCPro:main

Conversation

@ArmaanCPro
Copy link
Contributor

This references issue #321.

It was a stupidly simple 1-line solution, but hopefully it'll help projects that build using the latest version of MSVC.


Resolved the warning on MSVC:
inja\include\inja\parser.hpp(662) : warning C4702: unreachable code.

The statement current_block = nullptr was unreachable after the default case of the switch statement that threw, so I just moved the line up to be inside of the default case.

@villevoutilainen
Copy link

Three comments:

  1. MSVC is correct, that resetting of current_token after the switch is unreachable, the parser either reaches EOF and returns, or throws
  2. None of the other branches that throw an error reset current_token
  3. ..and that looks intentional; if the parser throws, the calling code can show the current_token in case of a parser error. So just remove that outside-switch resetting of current_token, and don't move it.

@pantor pantor merged commit 751eab3 into pantor:main Jan 9, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants