snazzy-d / sdc

The Snazzy D Compiler
MIT License
246 stars 55 forks source link

Explicitly convert loop indexes from `size_t` to `uint` #332

Closed 0xEAB closed 9 months ago

0xEAB commented 10 months ago

Explicitly convert loop indexes from size_t to uint.

Fixes these deprecation warnings:

src/d/llvm/evaluator.d(382): Deprecation: foreach: loop index implicitly converted from `size_t` to `uint`
src/d/llvm/expression.d(442): Deprecation: foreach: loop index implicitly converted from `size_t` to `uint`
deadalnix commented 9 months ago

The intention is good, but execution, not so much.

First, the static if is completely unnecessary. But second, we actually aren't asserting what we actually want to assert: that the cast isn't losing information. Now, sure, one can argue the checks are equivalent, and this is true in this version of the code, but will it be in tomorow's? Let's check what we actually want to check here.