# Parser does not catch Generator Expression Error

**URL:** <https://discourse.cmake.org/t/parser-does-not-catch-generator-expression-error/4877>\
**Category:** Code\
**Created:** [January 19, 2022, 7:23pm UTC](https://discourse.cmake.org/t/parser-does-not-catch-generator-expression-error/4877 "2022-01-19T19:23:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gopal\_Raghavan](https://discourse.cmake.org/user_avatar/discourse.cmake.org/gopal_raghavan/32/2119_2.png) [@Gopal\_Raghavan](https://discourse.cmake.org/u/Gopal_Raghavan)\
**Post date:** [January 19, 2022, 7:23pm UTC](https://discourse.cmake.org/t/parser-does-not-catch-generator-expression-error/4877/1 "2022-01-19T19:23:10Z")

</div>

When using the following expression:  
`$<$<OR:$<CONFIG:flash_release>,$<CONFIG:flash_debug>>:${LINKER_FLAGS_FLASH_COMMON}>`,  
if i am missing the final `>`, cmake generator does not catch this error. This results in weird linker errors in the build phase.

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [January 19, 2022, 9:59pm UTC](https://discourse.cmake.org/t/parser-does-not-catch-generator-expression-error/4877/2 "2022-01-19T21:59:33Z")

</div>

I haven’t checked the code, but what I expect is happening is that all the inner generator expressions are being correctly identified and expanded, but when the outermost one is missing the final `>`, CMake doesn’t see a generator expression after expanding all the inner ones and so it just treats that outermost one as an ordinary string (I think it’s logic is to only treat something as a generator expression if it is indeed a generator expression, but if you omit the `>`, then it isn’t one and so it has to be treated as a plain string).

One could potentially mount an argument that a warning could be issued if the value starts with `$<` and doesn’t end with `>`. It might be less clear-cut if an unmatched `$<` appears somewhere other than at the start of the value.

---

<div class="post-metadata">

**Author:** ![Gopal\_Raghavan](https://discourse.cmake.org/user_avatar/discourse.cmake.org/gopal_raghavan/32/2119_2.png) [@Gopal\_Raghavan](https://discourse.cmake.org/u/Gopal_Raghavan)\
**Post date:** [January 19, 2022, 10:09pm UTC](https://discourse.cmake.org/t/parser-does-not-catch-generator-expression-error/4877/3 "2022-01-19T22:09:38Z")

</div>

You are spot on. It does treat the outermost as a string. A warning would be be very helpful instead of getting lost in a bizarre linker message (in my case).  
gopal
