Comments (1)
What is the accepted outcome in this situation?
All cases except for the ref HyalosTrackerObj[T, typeof N]
one should work. Whether typeof N
itself should be allowed is not certain at this time, since whether tyStatic
is a type or a value (or both) is still fuzzy, but using using typedesc[static int]
as the argument to a generic parameter which is constrained to a static int
is always wrong.
Under previous main line versions, I am used to the first 'mostly' functioning.
The code responsible for reporting an error has not changed since the fork happened. Using a recent-ish version of Nim, I also get the "type expected" error.
The fundamental reason why case 1 fails and case 2 (erroneously) succeeds is that when the ref HyalosTrackerObj
type construction is analyzed, the compiler only knows that HylaosTrackerObj
is a generic type, but not what its generic parameters are.
For forwarded generic types, the compiler makes the assumption that all generic parameters want types (see semtypes.nim:1729
for the code that handles this case), even if that turns out to be wrong, hence typeof N
being accepted but not N
(a static
-constrained generic parameter cannot be used in a type/typedesc context).
If you were to swap the definitions in the typeof N
case, the compiler would correctly report an error.
from nimskull.
Related Issues (20)
- 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
- Compiler crash with new mangling module with a cdecl,varargs proc HOT 1
- using `NimNode` in run-time code crashes the compiler
- `nim e` crashes when user-defined hooks are used HOT 1
- Compiler crash with ambiguous function call HOT 1
- overflow checks cannot be disabled for integer negation in the VM HOT 2
- dereferencing `var|lent uint(8|16|32)` yields wrong value in VM HOT 2
- double destroy with `sink` and generic tuple type
- cgen incorrectly considers type to have C array semantics HOT 2
- cgen generates the same struct twice when importing a distinct object HOT 1
- cgen behaviour for importc objects using importc objects internally HOT 2
- Missing `=destroy` call for `discard`ed complex expressions HOT 1
- RTTI hook type erasure is considered undefined behavior by clang HOT 3
- Variables in `{.compileTime.}` cannot be captured if the capturing closure is nested twice HOT 1
- Generic constraints can be bypassed using `proc` default initialization
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.