status-im / nim-stew

stew is collection of utilities, std library extensions and budding libraries that are frequently used at Status, but are too small to deserve their own git repository.
133 stars 18 forks source link

don't mark `declval` as `{.compileTime.}` #190

Open metagn opened 1 year ago

metagn commented 1 year ago

declval is meant to be used to determine types of expressions, and never be executed (https://github.com/status-im/nim-stew/pull/33). However it's marked {.compileTime.}, which would normally make it always execute during constant folding, but due to a bug in Nim (https://github.com/nim-lang/Nim/issues/10753), generic procs like declval do not undergo constant folding. So the {.compileTime.} annotation is removed for this to work when the bug in Nim is fixed.

(Unfortunately this still only errors at execution time, I don't know a mechanism that errors at compile time but only outside typeof/concepts)

metagn commented 10 months ago

Would be nice if this got reviewed, this is needed for CI to pass with the bugfix in https://github.com/nim-lang/Nim/pull/22022, and this library is probably too active/important to fork for CI.