Git Product home page Git Product logo

Comments (4)

SeanTAllen avatar SeanTAllen commented on June 2, 2024

This isn't an actionable bug. In keeping with our getting help documentation, please ask "how do I" questions in the Zulip.

from ponyc.

SeanTAllen avatar SeanTAllen commented on June 2, 2024

Closing

from ponyc.

tetotechy avatar tetotechy commented on June 2, 2024

Apologies for not making myself clear. What I meant is that the following code compiles (I changed the example a bit):

actor Main
  new create(env: Env) =>
    Foo[U8, Array[U8]](env, 10)(3)
  

class Foo[T: Stringable val, Arr: Seq[T] ref = Array[T]]
  let _env: Env
  var arr: Arr = Arr
  
  new create(env: Env, v: T) =>
    _env = env
    arr.push(v)
    
  fun ref apply(v: T) =>
    arr.push(v)
    for el in arr.values() do
      _env.out.print(el.string())
    end

whilst omitting the second generic type when instantiating - to leverage the default type, the compiler gives an error:

actor Main
  new create(env: Env) =>
    Foo[U8](env, 10)(3)
  

class Foo[T: Stringable val, Arr: Seq[T] ref = Array[T]]
  let _env: Env
  var arr: Arr = Arr
  
  new create(env: Env, v: T) =>
    _env = env
    arr.push(v)
    
  fun ref apply(v: T) =>
    arr.push(v)
    for el in arr.values() do
      _env.out.print(el.string())
    end

No problems to revert to Zulip, happy to do so if this is expected behavior. Thanks!

from ponyc.

jemc avatar jemc commented on June 2, 2024

This is definitely something that I would have expected to work as desired.

The key issue here is that the compiler is comparing the constraint Seq[U8] to the default arg Array[T]. But to make this compile correctly it would either need to compare Seq[T] withArray[T] or alternatively, Seq[U8] with Array[U8].

We discussed this a bit in the sync call today, but haven't done any triaging yet into why this doesn't work as expected today. Needs further troubleshooting.

from ponyc.

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.