Repository: seaofvoices/darklua
Pull request #119 (2023-08-08 04:23:31)

Fix bundling related issues
* Fix replace reference tokens internal rule to avoid crashes when bundling
* Fix remove_spaces rule for missing cases
* Fix remove_comments rule for missing cases

- [x] add entry to the changelog


github-actions[bot]: Coverage after merging <b>fix-bundling-related-issues</b> into <b>main</b> will be<table><tbody><tr><th>90.05%</th></tr></tbody></table>

<details><summary>Coverage Report for Changed Files</summary><table><tbody><tr><th>File</th><th>Stmts</th><th>Branches</th><th>Funcs</th><th>Lines</th><th>Uncovered Lines</th></tr><tr><td colspan='6'><b>src/frontend</b></td></tr><tr><td>&nbsp; &nbsp;<a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs'>resources.rs</a></td><td><b>78.44%</b></td><td>100%</td><td><b>70.21%</b></td><td><b>80.18%</b></td><td><a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L124'>124</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L126-L129'>126&ndash;129</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L13'>13</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L130-L131'>130&ndash;131</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L135-L138'>135&ndash;138</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L151-L154'>151&ndash;154</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L161-L164'>161&ndash;164</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L177'>177</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L225'>225</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L232-L234'>232&ndash;234</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L236-L241'>236&ndash;241</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L57-L58'>57&ndash;58</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/resources.rs#L77'>77</a></td></tr><tr><td>&nbsp; &nbsp;<a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs'>worker.rs</a></td><td><b>70.81%</b></td><td>100%</td><td><b>63.16%</b></td><td><b>71.25%</b></td><td><a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L100-L107'>100&ndash;107</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L110'>110</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L114-L115'>114&ndash;115</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L118-L121'>118&ndash;121</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L140-L142'>140&ndash;142</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L162-L163'>162&ndash;163</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L165'>165</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L188'>188</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L193-L195'>193&ndash;195</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L197'>197</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L21'>21</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L229'>229</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L253-L257'>253&ndash;257</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L259'>259</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L283-L286'>283&ndash;286</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L291-L296'>291&ndash;296</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L298-L305'>298&ndash;305</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L326-L328'>326&ndash;328</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L336-L338'>336&ndash;338</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L346-L348'>346&ndash;348</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L356-L358'>356&ndash;358</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L360-L361'>360&ndash;361</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L370'>370</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L406'>406</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L422-L424'>422&ndash;424</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L439-L441'>439&ndash;441</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L49-L56'>49&ndash;56</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/frontend/worker.rs#L86-L87'>86&ndash;87</a></td></tr><tr><td colspan='6'><b>src/nodes</b></td></tr><tr><td>&nbsp; &nbsp;<a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/token.rs'>token.rs</a></td><td><b>93.42%</b></td><td>100%</td><td><b>95.45%</b></td><td><b>92.96%</b></td><td><a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/token.rs#L137-L140'>137&ndash;140</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/token.rs#L189'>189</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/token.rs#L195-L197'>195&ndash;197</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/token.rs#L230'>230</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/token.rs#L250'>250</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/token.rs#L68'>68</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/token.rs#L77'>77</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/token.rs#L90'>90</a></td></tr><tr><td colspan='6'><b>src/nodes/expressions</b></td></tr><tr><td>&nbsp; &nbsp;<a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs'>if_expression.rs</a></td><td><b>72.62%</b></td><td>100%</td><td><b>66.67%</b></td><td><b>74.24%</b></td><td><a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs#L100-L102'>100&ndash;102</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs#L153-L159'>153&ndash;159</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs#L213-L216'>213&ndash;216</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs#L219-L222'>219&ndash;222</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs#L231-L234'>231&ndash;234</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs#L263-L267'>263&ndash;267</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs#L270'>270</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs#L277-L280'>277&ndash;280</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs#L282-L285'>282&ndash;285</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs#L29'>29</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs#L292-L295'>292&ndash;295</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/expressions/if_expression.rs#L30-L32'>30&ndash;32</a></td></tr><tr><td colspan='6'><b>src/nodes/statements</b></td></tr><tr><td>&nbsp; &nbsp;<a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/statements/numeric_for.rs'>numeric_for.rs</a></td><td><b>81.01%</b></td><td>100%</td><td><b>75.86%</b></td><td><b>82.17%</b></td><td><a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/statements/numeric_for.rs#L153-L155'>153&ndash;155</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/statements/numeric_for.rs#L178-L183'>178&ndash;183</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/nodes/statements/numeric_for.rs#L47-L56'>47&ndash;56</a></td></tr><tr><td colspan='6'><b>src/rules</b></td></tr><tr><td>&nbsp; &nbsp;<a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/rules/replace_referenced_tokens.rs'>replace_referenced_tokens.rs</a></td><td><b>94.47%</b></td><td>100%</td><td><b>91.30%</b></td><td><b>95.42%</b></td><td><a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/rules/replace_referenced_tokens.rs#L171-L173'>171&ndash;173</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/rules/replace_referenced_tokens.rs#L9'>9</a>, <a href='https://github.com/seaofvoices/darklua/blob/8a136969141bb819687d348c9fa78c73d0d01c39/src/rules/replace_referenced_tokens.rs#L93'>93</a></td></tr></tbody></table></details>
github-actions[bot]: Coverage after merging <b>fix-bundling-related-issues</b> into <b>main</b> will be<table><tbody><tr><th>90.07%</th></tr></tbody></table>

<details><summary>Coverage Report for Changed Files</summary><table><tbody><tr><th>File</th><th>Stmts</th><th>Branches</th><th>Funcs</th><th>Lines</th><th>Uncovered Lines</th></tr><tr><td colspan='6'><b>src/frontend</b></td></tr><tr><td>&nbsp; &nbsp;<a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs'>resources.rs</a></td><td><b>78.44%</b></td><td>100%</td><td><b>70.21%</b></td><td><b>80.18%</b></td><td><a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L124'>124</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L126-L129'>126&ndash;129</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L13'>13</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L130-L131'>130&ndash;131</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L135-L138'>135&ndash;138</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L151-L154'>151&ndash;154</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L161-L164'>161&ndash;164</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L177'>177</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L225'>225</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L232-L234'>232&ndash;234</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L236-L241'>236&ndash;241</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L57-L58'>57&ndash;58</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/resources.rs#L77'>77</a></td></tr><tr><td>&nbsp; &nbsp;<a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs'>worker.rs</a></td><td><b>70.81%</b></td><td>100%</td><td><b>63.16%</b></td><td><b>71.25%</b></td><td><a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L100-L107'>100&ndash;107</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L110'>110</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L114-L115'>114&ndash;115</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L118-L121'>118&ndash;121</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L140-L142'>140&ndash;142</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L162-L163'>162&ndash;163</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L165'>165</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L188'>188</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L193-L195'>193&ndash;195</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L197'>197</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L21'>21</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L229'>229</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L253-L257'>253&ndash;257</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L259'>259</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L283-L286'>283&ndash;286</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L291-L296'>291&ndash;296</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L298-L305'>298&ndash;305</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L326-L328'>326&ndash;328</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L336-L338'>336&ndash;338</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L346-L348'>346&ndash;348</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L356-L358'>356&ndash;358</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L360-L361'>360&ndash;361</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L370'>370</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L406'>406</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L422-L424'>422&ndash;424</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L439-L441'>439&ndash;441</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L49-L56'>49&ndash;56</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/frontend/worker.rs#L86-L87'>86&ndash;87</a></td></tr><tr><td colspan='6'><b>src/nodes</b></td></tr><tr><td>&nbsp; &nbsp;<a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/token.rs'>token.rs</a></td><td><b>93.42%</b></td><td>100%</td><td><b>95.45%</b></td><td><b>92.96%</b></td><td><a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/token.rs#L137-L140'>137&ndash;140</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/token.rs#L189'>189</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/token.rs#L195-L197'>195&ndash;197</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/token.rs#L230'>230</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/token.rs#L250'>250</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/token.rs#L68'>68</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/token.rs#L77'>77</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/token.rs#L90'>90</a></td></tr><tr><td colspan='6'><b>src/nodes/expressions</b></td></tr><tr><td>&nbsp; &nbsp;<a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs'>if_expression.rs</a></td><td><b>72.62%</b></td><td>100%</td><td><b>66.67%</b></td><td><b>74.24%</b></td><td><a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs#L100-L102'>100&ndash;102</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs#L153-L159'>153&ndash;159</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs#L213-L216'>213&ndash;216</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs#L219-L222'>219&ndash;222</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs#L231-L234'>231&ndash;234</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs#L263-L267'>263&ndash;267</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs#L270'>270</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs#L277-L280'>277&ndash;280</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs#L282-L285'>282&ndash;285</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs#L29'>29</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs#L292-L295'>292&ndash;295</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/expressions/if_expression.rs#L30-L32'>30&ndash;32</a></td></tr><tr><td colspan='6'><b>src/nodes/statements</b></td></tr><tr><td>&nbsp; &nbsp;<a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/statements/numeric_for.rs'>numeric_for.rs</a></td><td><b>81.01%</b></td><td>100%</td><td><b>75.86%</b></td><td><b>82.17%</b></td><td><a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/statements/numeric_for.rs#L153-L155'>153&ndash;155</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/statements/numeric_for.rs#L178-L183'>178&ndash;183</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/nodes/statements/numeric_for.rs#L47-L56'>47&ndash;56</a></td></tr><tr><td colspan='6'><b>src/rules</b></td></tr><tr><td>&nbsp; &nbsp;<a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/rules/replace_referenced_tokens.rs'>replace_referenced_tokens.rs</a></td><td><b>94.47%</b></td><td>100%</td><td><b>91.30%</b></td><td><b>95.42%</b></td><td><a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/rules/replace_referenced_tokens.rs#L171-L173'>171&ndash;173</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/rules/replace_referenced_tokens.rs#L9'>9</a>, <a href='https://github.com/seaofvoices/darklua/blob/aad5e8b664074664ecd41387bb4f1145c986216d/src/rules/replace_referenced_tokens.rs#L93'>93</a></td></tr></tbody></table></details>

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1b29a19..73d2650 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
 
 ## Unreleased
 
+* fix crashes when bundling code and fix `remove_spaces` and `remove_comments` rule for missing cases (if expressions and numeric for) ([#119](https://github.com/seaofvoices/darklua/pull/119))
+
 ## 0.10.1
 
 * make rojo sourcemap paths relative to its file location ([#117](https://github.com/seaofvoices/darklua/pull/117))
diff --git a/src/frontend/resources.rs b/src/frontend/resources.rs
index 2167d2b..ef7c7b0 100644
--- a/src/frontend/resources.rs
+++ b/src/frontend/resources.rs
@@ -1,11 +1,11 @@
 use std::{
-    cell::RefCell,
     collections::HashMap,
     ffi::OsStr,
     fs::{self, File},
     io::{self, BufWriter, ErrorKind as IOErrorKind, Write},
     iter,
     path::{Path, PathBuf},
+    sync::{Arc, Mutex},
 };
 
 use crate::utils::normalize_path;
@@ -13,14 +13,14 @@ use crate::utils::normalize_path;
 #[derive(Debug, Clone)]
 enum Source {
     FileSystem,
-    Memory(RefCell<HashMap<PathBuf, String>>),
+    Memory(Arc<Mutex<HashMap<PathBuf, String>>>),
 }
 
 impl Source {
     pub fn exists(&self, location: &Path) -> ResourceResult<bool> {
         match self {
             Self::FileSystem => Ok(location.exists()),
-            Self::Memory(data) => Ok(data.borrow().contains_key(&normalize_path(location))),
+            Self::Memory(data) => Ok(data.lock().unwrap().contains_key(&normalize_path(location))),
         }
     }
 
@@ -28,7 +28,7 @@ impl Source {
         let is_directory = match self {
             Source::FileSystem => self.exists(location)? && location.is_dir(),
             Source::Memory(data) => {
-                let data = data.borrow();
+                let data = data.lock().unwrap();
                 let location = normalize_path(location);
 
                 data.iter()
@@ -42,7 +42,7 @@ impl Source {
         let is_file = match self {
             Source::FileSystem => self.exists(location)? && location.is_file(),
             Source::Memory(data) => {
-                let data = data.borrow();
+                let data = data.lock().unwrap();
                 let location = normalize_path(location);
 
                 data.contains_key(&location)
@@ -58,7 +58,7 @@ impl Source {
                 _ => ResourceError::io_error(location, err),
             }),
             Self::Memory(data) => {
-                let data = data.borrow();
+                let data = data.lock().unwrap();
                 let location = normalize_path(location);
 
                 data.get(&location)
@@ -84,7 +84,7 @@ impl Source {
                     .map_err(|err| ResourceError::io_error(location, err))
             }
             Self::Memory(data) => {
-                let mut data = data.borrow_mut();
+                let mut data = data.lock().unwrap();
                 data.insert(normalize_path(location), content.to_string());
                 Ok(())
             }
@@ -96,7 +96,7 @@ impl Source {
             Self::FileSystem => Box::new(walk_file_system(location.to_path_buf()))
                 as Box<dyn Iterator<Item = PathBuf>>,
             Self::Memory(data) => {
-                let data = data.borrow();
+                let data = data.lock().unwrap();
                 let location = normalize_path(location);
                 let mut paths: Vec<_> = data.keys().map(normalize_path).collect();
                 paths.retain(|path| path.starts_with(&location));
diff --git a/src/frontend/worker.rs b/src/frontend/worker.rs
index 7883157..0699c87 100644
--- a/src/frontend/worker.rs
+++ b/src/frontend/worker.rs
@@ -352,7 +352,7 @@ impl<'a> Worker<'a> {
 
         log::trace!("begin generating code for `{}`", source_display);
 
-        if cfg!(debug_assertions) && log::log_enabled!(log::Level::Trace) {
+        if cfg!(test) || (cfg!(debug_assertions) && log::log_enabled!(log::Level::Trace)) {
             log::trace!(
                 "generate AST debugging view at `{}`",
                 data.output().display()
diff --git a/src/nodes/expressions/if_expression.rs b/src/nodes/expressions/if_expression.rs
index 4bf28fe..6d9f9df 100644
--- a/src/nodes/expressions/if_expression.rs
+++ b/src/nodes/expressions/if_expression.rs
@@ -245,21 +245,25 @@ impl IfExpressionTokens {
     pub fn clear_comments(&mut self) {
         self.r#if.clear_comments();
         self.then.clear_comments();
+        self.r#else.clear_comments();
     }
 
     pub fn clear_whitespaces(&mut self) {
         self.r#if.clear_whitespaces();
         self.then.clear_whitespaces();
+        self.r#else.clear_whitespaces();
     }
 
     pub(crate) fn replace_referenced_tokens(&mut self, code: &str) {
         self.r#if.replace_referenced_tokens(code);
         self.then.replace_referenced_tokens(code);
+        self.r#else.replace_referenced_tokens(code);
     }
 
     pub(crate) fn shift_token_line(&mut self, amount: usize) {
         self.r#if.shift_token_line(amount);
         self.then.shift_token_line(amount);
+        self.r#else.shift_token_line(amount);
     }
 }
 
diff --git a/src/nodes/statements/numeric_for.rs b/src/nodes/statements/numeric_for.rs
index f06e89e..412c46d 100644
--- a/src/nodes/statements/numeric_for.rs
+++ b/src/nodes/statements/numeric_for.rs
@@ -155,24 +155,28 @@ impl NumericForStatement {
     }
 
     pub fn clear_comments(&mut self) {
+        self.identifier.clear_comments();
         if let Some(tokens) = &mut self.tokens {
             tokens.clear_comments();
         }
     }
 
     pub fn clear_whitespaces(&mut self) {
+        self.identifier.clear_whitespaces();
         if let Some(tokens) = &mut self.tokens {
             tokens.clear_whitespaces();
         }
     }
 
     pub(crate) fn replace_referenced_tokens(&mut self, code: &str) {
+        self.identifier.replace_referenced_tokens(code);
         if let Some(tokens) = &mut self.tokens {
             tokens.replace_referenced_tokens(code);
         }
     }
 
     pub(crate) fn shift_token_line(&mut self, amount: usize) {
+        self.identifier.shift_token_line(amount);
         if let Some(tokens) = &mut self.tokens {
             tokens.shift_token_line(amount);
         }
diff --git a/src/nodes/token.rs b/src/nodes/token.rs
index fe623d7..90545d2 100644
--- a/src/nodes/token.rs
+++ b/src/nodes/token.rs
@@ -68,7 +68,6 @@ impl Trivia {
                     panic!("unable to extract code from position: {} - {}", start, end);
                 })
             }
-            // .expect("unable to extract code from position"),
             Position::LineNumber { content, .. } | Position::Any { content } => content,
         }
     }
diff --git a/src/rules/replace_referenced_tokens.rs b/src/rules/replace_referenced_tokens.rs
index 5253328..b666ad4 100644
--- a/src/rules/replace_referenced_tokens.rs
+++ b/src/rules/replace_referenced_tokens.rs
@@ -184,7 +184,11 @@ impl RuleConfiguration for ReplaceReferencedTokens {
 #[cfg(test)]
 mod test {
     use super::*;
-    use crate::rules::Rule;
+    use crate::{
+        generator::{LuaGenerator, TokenBasedLuaGenerator},
+        rules::{ContextBuilder, Rule},
+        Parser, Resources,
+    };
 
     use insta::assert_json_snapshot;
 
@@ -198,4 +202,39 @@ mod test {
 
         assert_json_snapshot!("default_replace_referenced_tokens", rule);
     }
+
+    fn test_code(code: &str) {
+        let parser = Parser::default().preserve_tokens();
+
+        let mut block = parser.parse(code).expect("unable to parse code");
+
+        ReplaceReferencedTokens::default().flawless_process(
+            &mut block,
+            &ContextBuilder::new(".", &Resources::from_memory(), code).build(),
+        );
+
+        // provide invalid code to verify if the ReplaceReferencedTokens left token
+        // references, which will cause the TokenBasedLuaGenerator to panic
+        let mut generator = TokenBasedLuaGenerator::new("");
+
+        generator.write_block(&block);
+    }
+
+    #[test]
+    fn test_fuzzed_case_a() {
+        let code = include_str!("../../tests/fuzzed_test_cases/a.lua");
+        test_code(code);
+    }
+
+    #[test]
+    fn test_fuzzed_case_b() {
+        let code = include_str!("../../tests/fuzzed_test_cases/b.lua");
+        test_code(code);
+    }
+
+    #[test]
+    fn test_fuzzed_case_c() {
+        let code = include_str!("../../tests/fuzzed_test_cases/c.lua");
+        test_code(code);
+    }
 }


Test patch:
diff --git a/src/rules/snapshots/darklua_core__rules__remove_comments__test__remove_comments_in_code.snap b/src/rules/snapshots/darklua_core__rules__remove_comments__test__remove_comments_in_code.snap
index 6d16f93..7995018 100644
--- a/src/rules/snapshots/darklua_core__rules__remove_comments__test__remove_comments_in_code.snap
+++ b/src/rules/snapshots/darklua_core__rules__remove_comments__test__remove_comments_in_code.snap
@@ -55,5 +55,5 @@ object : method  ({ key  = [[true]], [ true ] = ( nil )
  }, ...  )
 
 object .  field : method 
-{ if value then ok else err, {  },  }
+{ if   value   then    ok   else   err, {  },  }
 
diff --git a/src/rules/snapshots/darklua_core__rules__remove_spaces__test__remove_spaces_in_code.snap b/src/rules/snapshots/darklua_core__rules__remove_spaces__test__remove_spaces_in_code.snap
index 4f43e15..1b11993 100644
--- a/src/rules/snapshots/darklua_core__rules__remove_spaces__test__remove_spaces_in_code.snap
+++ b/src/rules/snapshots/darklua_core__rules__remove_spaces__test__remove_spaces_in_code.snap
@@ -37,7 +37,7 @@ local a--[[a]],b,c=id+--[[add]]id,nil--[[nothing]]
 local function fn--[[function name]](p1,p2-- p2
 ,p3,...)end
 
-for i =10,1,-3 do-- comment
+for i=10,1,-3 do-- comment
 continue--skip
 end
 
@@ -55,4 +55,4 @@ object:method--[[call]]({key--[[]]=[[true]],[true--[[key]] ]=(nil)-- nil
 },...--[[forward args]])
 
 object.--[[get field]]field:method--
-{if value then ok else err,{--[[empty table]]},--[[trailing comma]]}
+{if--[[condition]]value then--[[true]]ok else--[[false]]err,{--[[empty table]]},--[[trailing comma]]}
diff --git a/tests/bundle.rs b/tests/bundle.rs
index e90a2a7..c8d8c1e 100644
--- a/tests/bundle.rs
+++ b/tests/bundle.rs
@@ -1,5 +1,6 @@
 use darklua_core::{process, Options, Resources};
 
+mod fuzz;
 mod utils;
 
 use utils::memory_resources;
@@ -58,6 +59,15 @@ fn skip_require_call_with_2_arguments() {
 }
 
 mod without_rules {
+    use std::time::Duration;
+
+    use darklua_core::{
+        generator::{LuaGenerator, ReadableLuaGenerator},
+        nodes::{Block, Expression, ReturnStatement},
+    };
+
+    use crate::fuzz::{Fuzz, FuzzContext};
+
     use super::*;
 
     fn process_main(resources: &Resources, snapshot_name: &'static str) {
@@ -488,6 +498,48 @@ data:
         process_main(&resources, "require_small_bundle_case");
     }
 
+    #[test]
+    fn fuzz_bundle() {
+        utils::run_for_minimum_time(Duration::from_millis(250), || {
+            let mut fuzz_context = FuzzContext::new(20, 40);
+            let mut block = Block::fuzz(&mut fuzz_context);
+            block.set_last_statement(ReturnStatement::one(Expression::nil()));
+
+            let mut generator = ReadableLuaGenerator::new(80);
+
+            generator.write_block(&block);
+
+            let block_file = generator.into_string();
+
+            let resources = memory_resources!(
+                "src/value.lua" => &block_file,
+                "src/main.lua" => "local value = require('./value')",
+                ".darklua.json" => DARKLUA_BUNDLE_ONLY_RETAIN_LINES_CONFIG,
+            );
+            let resource_ref = &resources;
+
+            let result = std::panic::catch_unwind(|| {
+                process(
+                    resource_ref,
+                    Options::new("src/main.lua").with_output("out.lua"),
+                )
+                .result()
+                .unwrap();
+            });
+
+            result
+                .map_err(|err| {
+                    std::fs::write("fuzz_bundle_failure.repro.txt", block_file).unwrap();
+
+                    let out = resources.get("out.lua").unwrap();
+                    std::fs::write("fuzz_bundle_failure.txt", out).unwrap();
+
+                    err
+                })
+                .unwrap();
+        })
+    }
+
     mod cyclic_requires {
         use super::*;
 
diff --git a/tests/fuzz_generator.rs b/tests/fuzz_generator.rs
index a9cd253..08e71ef 100644
--- a/tests/fuzz_generator.rs
+++ b/tests/fuzz_generator.rs
@@ -6,7 +6,7 @@ use darklua_core::{
         BinaryExpression, BinaryOperator, Expression, LastStatement, UnaryExpression, UnaryOperator,
     },
 };
-use std::time::{Duration, Instant};
+use std::time::Duration;
 
 mod fuzz;
 mod utils;
@@ -123,24 +123,13 @@ macro_rules! fuzz_test_block {
 }
 
 fn run_for_minimum_time<F: Fn()>(func: F) {
-    let duration = get_fuzz_duration();
-    let start = Instant::now();
-
-    loop {
-        func();
-
-        if Instant::now().duration_since(start) > duration {
-            break;
-        }
-    }
-}
-
-fn get_fuzz_duration() -> Duration {
     let millis = option_env!("FUZZ_DURATION_MILLISECONDS")
         .and_then(|value| value.parse::<u64>().ok())
         .unwrap_or(1500);
 
-    Duration::from_millis(millis)
+    let duration = Duration::from_millis(millis);
+
+    utils::run_for_minimum_time(duration, func);
 }
 
 fn fuzz_three_terms_binary_expressions<T: LuaGenerator + Clone>(generator: T) {
diff --git a/tests/fuzzed_test_cases/b.lua b/tests/fuzzed_test_cases/b.lua
new file mode 100644
index 0000000..f9bc690
--- /dev/null
+++ b/tests/fuzzed_test_cases/b.lua
@@ -0,0 +1,34 @@
+(0b10011001001011111110)((...){})
+
+function uYU2V:vnx26UF(FClA2m, NG91)
+    for ak8S={}, {}do
+        local function X5Gi(HC, eNA) end
+    end
+
+    local function Pzc(i, y, Muf, J9xNN, ...) end
+
+    unXK{}
+
+    function Nnugi.b2:ssFjy(RI2C, ZQq2Z, ...) end
+
+    AVU2Pl = jRG
+end
+
+ocvU[(false) % (IZZ)][(...)'*}-D'[false]], hcdmT[uJa6].Y, Aj5a'S'[false] = nil, false or {}
+
+repeat
+    for BAo4={}, {}, {}do
+        continue
+    end
+
+    local M79FL, qtFMb
+
+    continue
+until function(Yv, IUZl, ...) end
+
+for SUzr in {} do end
+
+if {} then
+end
+
+return nil
diff --git a/tests/fuzzed_test_cases/c.lua b/tests/fuzzed_test_cases/c.lua
new file mode 100644
index 0000000..7a87ead
--- /dev/null
+++ b/tests/fuzzed_test_cases/c.lua
@@ -0,0 +1,30 @@
+repeat
+    function P75j.lbVvDb2Q(Bof, oVik) end
+
+    for Z9r in 0b1000001110011110001 do end
+
+    while... do end
+
+    OJlQ6.S *= {}
+
+    local function hcfLMV(pY, Y1VqO, hmrm, tKmKa, ...) end
+until 0x2f1c
+
+while if sn4y then false else false do
+    local Tc
+
+    local function yPA(yNA, oZaVq8Z, ...) end
+end
+
+for HaJx=..., {}, {}do
+    if rT then
+    end
+
+    wsI ..= {}
+end
+
+repeat until Ep
+
+function ETN:KJ4y(sz, rsas7V, ...) end
+
+return nil
diff --git a/tests/test_cases/spaces_and_comments.lua b/tests/test_cases/spaces_and_comments.lua
index 66baa9d..babf6fc 100644
--- a/tests/test_cases/spaces_and_comments.lua
+++ b/tests/test_cases/spaces_and_comments.lua
@@ -51,4 +51,4 @@ object : method --[[call]] ({ key --[[]] = [[true]], [ true --[[key]]] = ( nil )
  }, ... --[[forward args]] )
 
 object . --[[get field]] field : method --
-{ if value then ok else err, { --[[empty table]] }, --[[trailing comma]] }
+{ if --[[condition]]  value   then --[[true]]   ok   else --[[false]]  err, { --[[empty table]] }, --[[trailing comma]] }
diff --git a/tests/utils.rs b/tests/utils.rs
index 327e9f5..8484380 100644
--- a/tests/utils.rs
+++ b/tests/utils.rs
@@ -1,5 +1,6 @@
 use std::panic::Location;
 use std::path::Path;
+use std::time::{Duration, Instant};
 
 use darklua_core::nodes::Block;
 use darklua_core::{Parser, ParserError, Resources};
@@ -68,16 +69,29 @@ pub fn snapshot_file_process_file_errors(
     });
 }
 
+#[allow(dead_code)]
+pub fn run_for_minimum_time<F: Fn()>(duration: Duration, func: F) {
+    let start = Instant::now();
+
+    loop {
+        func();
+
+        if Instant::now().duration_since(start) > duration {
+            break;
+        }
+    }
+}
+
 #[allow(unused_macros)]
 macro_rules! memory_resources {
-        ($($path:literal => $content:expr),+$(,)?) => ({
-            let resources = Resources::from_memory();
-            $(
-                resources.write($path, $content).unwrap();
-            )*
-            resources
-        });
-    }
+    ($($path:literal => $content:expr),+$(,)?) => ({
+        let resources = Resources::from_memory();
+        $(
+            resources.write($path, $content).unwrap();
+        )*
+        resources
+    });
+}
 
 #[allow(unused_imports)]
 pub(crate) use memory_resources;