Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
More or less correct (except untyped/typed failing and const arr = [] still working) but not the right solution. Fixes #23496 but not #23199 or #23534.
The right solution is to whitelist empty containers in specific contexts like #22716, specifically:
As arguments to untyped/typed parameters
As arguments to parameters, given they receive a concrete type when the match is over (match to the parameter, not the entire call, though we could maybe support this in the future so that #23534 actually compiles instead of just giving a legible error)
[] as an argument to the seq overload of @
In any context where type inference can be performed after the expression is compiled, as long as the type is re-checked for a concrete value. So (@[], 1) compiles if it's a variable initializer with an annotated type, but not as a call argument.
Sounds nice in principle but a fair bit of a refactor if we also include things like uninstantiated routines and maybe there are cases where the codegen depends on empty types. And there is stuff like typeof(@[]) etc.
More or less correct (except untyped/typed failing and
const arr = []
still working) but not the right solution. Fixes #23496 but not #23199 or #23534.The right solution is to whitelist empty containers in specific contexts like #22716, specifically:
untyped
/typed
parameters[]
as an argument to the seq overload of@
(@[], 1)
compiles if it's a variable initializer with an annotated type, but not as a call argument.Sounds nice in principle but a fair bit of a refactor if we also include things like uninstantiated routines and maybe there are cases where the codegen depends on empty types. And there is stuff like
typeof(@[])
etc.