Coder Social home page Coder Social logo

Comments (4)

jakemac53 avatar jakemac53 commented on July 17, 2024

It seems like it should infer the type String for the initial final banana = ... and then there should be an error when the augment final banana inherits that type, and tries to assign a function to it.

Yes, this is how it should work (not sure if it is specified explicitly). In the macro spec we do say this "We don't allow augmentations of existing declarations to contribute to inference, so in phase 3 type inference can be performed.". That should be clarified in the augmentations spec as well though, I don't see it there.

from language.

lrhn avatar lrhn commented on July 17, 2024

That's what I expected.

It does mean that var x; cannot be augmented to have a non-dynamic type by providing an initializer. Which I guess i fine, you should type your var x's that shouldn't be dynamic.

from language.

jakemac53 avatar jakemac53 commented on July 17, 2024

you should type your var x's that shouldn't be dynamic.

Exactly, without a user-visible initializer at the declaration site I think the explicit type is anyways warranted, even if we could infer types based off of a later provided initializer.

from language.

davidmorgan avatar davidmorgan commented on July 17, 2024

I think the remaining work here is clarifying in the augmentations spec? Thanks.

from language.

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.