ned14 / outcome

Provides very lightweight outcome<T> and result<T> (non-Boost edition)
https://ned14.github.io/outcome
Other
704 stars 62 forks source link

Cannot use expressions involving variables named `res` within `OUTCOME_TRYX` and friends #232

Closed burnpanck closed 4 years ago

burnpanck commented 4 years ago

The macro OUTCOME_TRYX(expr) introduces a local scope with a local variable by the name of res. If the expression expr contains a reference to an outer variable named res as-well, the compilation fails with use of "res" before deduction of auto (which is better than silently referring to the wrong variable). However, res is too a common name to be disallowed within that macro. Maybe a mechanism similar to OUTCOME_TRY_UNIQUE_NAME can be used, or at least something slightly longer would probably help.

ned14 commented 4 years ago

Fixed on the future v2.2 branch. Awaiting Boost release manager permission before can modify develop branch. Thanks for the bug report!