Comments (3)
This is a general problem not strictly related to void
. Generic parameters are ignored when comparing routine signatures for the purpose of disallowing re-definitions (refer to searchForProcAux
). For example:
proc test[T: int]() = discard
proc test[T: float]() = discard
# error: re-definition of test
proc test2[T: int](): T = discard
proc test2[T: float](): T = discard
# error: would lead to ambiguous calls
from nimskull.
I think discriminating based on generic parameter constraint types is reasonable, but looking for more input on that as well. Does it make sense that we differentiate based on generic parameters, in some fashion?
Assuming the above is true, then my mind turns to more practical concerns wrt implementation. I'm not sure if the current implementation can handle the weirder cases all that well, such as those involving type operations e.g.:
proc test[T: int]() = discard
proc test[T: float or int and not int]() = discard
proc test2[T: int](): T = discard
proc test2[T: float or int and not int](): T = discard
Perhaps we could start by swapping generic parameters for their constraints when considering signatures, that would mean test
would still result in a redefinition, as no parameters would take the constraints of their respective T
, and test2
would now work. At least the test
scenario veers into the whole aliases vs phantom types (branding).
from nimskull.
I would feel better about the branding situation if I could figure out how to .borrow.
distinct generics. I mean, I know that's already two sides of the pentagram of pain, but still...
from nimskull.
Related Issues (20)
- UFCS issue iterator into macro HOT 4
- set[int8] cannot initialized with values HOT 4
- linking error when using `{.compile.}` pragma on .c files with same name but located on different paths HOT 1
- dot function call syntax inside a template can't lookup symbols of an imported module when the template is called from another module HOT 1
- ` .threadvar`s aren't destroyed on thread exit HOT 1
- value is implicitly moved even though it's used afterwards HOT 2
- procedure result is not cleaned up if the procedure raises HOT 1
- compiler segfaults with `void` and `distinct` HOT 2
- compiler fatal error on lack of type arguments HOT 2
- what size should an empty object be? HOT 1
- The pointer passed to super type hook is not converted to the super type HOT 3
- closure iterator that captures the outer proc environment generates incompatible pointer assignments HOT 1
- Compiler crash (missing body) with declaration of inline proc HOT 6
- Compiler crash with bogus for loop HOT 3
- t02_argument_passing fails to compile with gcc 14 HOT 1
- tprocedural_views fails to compile with gcc 14 HOT 1
- macro generated objects with field name containing '`' cannot be accessed HOT 1
- Crash in transf due to malformed proc passed as argument HOT 1
- compiler crashes when using erroneous generic routine symbol as call argument
- Strings freed prematurely when used in a loop HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nimskull.