Add cop to disallow case structures where all when clauses are proc literals - #797
Add cop to disallow case structures where all when clauses are proc literals#797rwstauner wants to merge 1 commit into
Conversation
5230147 to
f705f00
Compare
|
This feels like one of those things where maybe we should be taking a look at solving it at the interpreter level. Is there a reason an |
…iterals An if/else tree is equivalent without allocating the procs. This also triggers if the only non-proc clauses are literal values.
b932fd3 to
c4832ff
Compare
The only reason a proc is used here is to bend the condition to fit into the case statement. Since you wouldn't do that using if/else, there's no special handling needed when using the more natural syntax. It would be possible to optimize this in the interpreter (I believe we can reduce the allocation count by caching the proc at the parser level), but in order to inline the block to remove all the overhead I'm not convinced the interpeter bloat needed to accomplish the task is worth it. |
An if/else tree is equivalent without allocating the procs.
This also triggers if the only non-proc clauses are literal values.