-
-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trait default method segfault #4451
Comments
Code in question: actor Main
new create(env: Env) =>
Foo[String box](env, "message")
Foo[String box].double()(env, "message")
trait Printer[T: Stringable box]
fun apply(env: Env, msg: T)
fun double(): Printer[T] =>
object ref is Printer[T]
fun apply(env: Env, msg: T) =>
env.out.print("First " + msg.string())
env.out.print("Second " + msg.string())
end
class Foo[T: Stringable box] is Printer[T]
fun apply(env: Env, msg: T) =>
env.out.print("Just one " + msg.string()) |
Here's the backtrace from a debug version of the compiler:
For the uninitated, when you go to look at |
The AST item in question when we go boom appears to be a
Next step is additional debugging to figure out what is the unexpected bit and probably one of:
in all likelihood, its the first in that list. |
Changing to: actor Main
new create(env: Env) =>
Foo[String box](env, "message")
Foo[String box].double()(env, "message")
trait Printer[T: Stringable box]
fun apply(env: Env, msg: T)
fun double(): Printer[T] =>
Foo[T]
class Foo[T: Stringable box] is Printer[T]
fun apply(env: Env, msg: T) =>
env.out.print("Just one " + msg.string()) fixes the issue, so, focus on the object literal when debugging. |
Hi!
Pony is an amazing project, it was love at first sight for me. Having tried so many other languages, I can tell you I am having a great deal of fun and satisfaction coding in Pony. Congratulations, please keep it up!
I have bumped into this problem trying to define a default trait method that returns a literal object. The example is overly-simplified and looks useless and dumb, but the intent is to provide a capability-adding method to the object adopting the trait. New capabilities are additive, so it makes sense that the new augmented object, in turn, implement the trait.
As an alternative solution, I have implemented a separate class that returns the object literal in its
apply
method.I am wondering whether I am hitting some consistent limitation I am not aware of, or this might be a bug.
Thanks!
The text was updated successfully, but these errors were encountered: