Coder Social home page Coder Social logo

Comments (1)

zerbina avatar zerbina commented on August 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.