Coder Social home page Coder Social logo

Comments (6)

lrhn avatar lrhn commented on July 28, 2024

Probably a name mangling issue.

from sdk.

sigmundch avatar sigmundch commented on July 28, 2024

Thanks @Diaga for the very nice repro!

Here is a simplified example illustrating the problem in a standalone application:

class B<T> {}
class B$ {}

main() => B<int>();

It appears DDC introduces a helper declaration when defining generic classes, but it is not checking whether the name for the helper conflicts with other definitions in the same module. In the example above, it introduces a helper called B$ to represent the generic instantiation of B, but B$ is also the declaration of the second class. When the latter overrides the former, it makes uses of the former invalid (like the instantiation of B<int>())

from sdk.

sigmundch avatar sigmundch commented on July 28, 2024

It's worth noting that this also happens with other conflicting declarations. For example:

class B<T> {}
final B$ = 0;
main() => B<int>();

So it's not sufficient to look for conflicts among classes. The error is slightly different in this case, but the cause is the same.

from sdk.

Markzipan avatar Markzipan commented on July 28, 2024

DDC emits auxiliary classes (and other top level identifiers) for generics and other structures with a $ suffix (see here). Lemme take a look at making these temporary Ids instead, which obey the built-in renaming semantics.

Thanks for the great repros, everyone!

from sdk.

Markzipan avatar Markzipan commented on July 28, 2024

Closing the loop here, DDC implicitly emits a generic object constructors as their original class name + $. The renaming logic here is a tricky to clean up (we can't just use temporaries since this "API" needs to be stable across our runtime). The workaround is simple (i.e., avoid creating top level elements named X$ if X is a generic class), but we can obfuscate the name in the short term if this becomes a blocker.

from sdk.

lrhn avatar lrhn commented on July 28, 2024

Consider working towards a fix. I expect names with $ in then may get more prevalent with macros.
(You could change all $s in the original name to $$_ and then any $ you insert yourself will not cause it to be equal to a source $).

from sdk.

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.