Should abstract + default body be an error when two traits declare the same method? #5829
SeanTAllen
started this conversation in
ponyc
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
When two traits declare the same method and both provide a default body, the compiler errors: "multiple possible bodies for method hello, local disambiguation required." Two abstract declarations work too — the implementing type must provide its own body, no ambiguity. But there's a third case. One trait declares the method abstract, the other provides a default body. The compiler silently adopts the default body.
The abstract declaration and the default body are competing declarations from different traits. A
Serializabletrait with an abstractserializeand aPrintabletrait with a defaultserializeare unrelated methods with the same name. The implementing type getsPrintable's body with no error.Pony has no mechanism for local disambiguation — no way for an implementing type to say "use this trait's body for this method."
This came up during #5825 / #5827, which fixed a crash when combining traits this way. The crash is gone, but the silent adoption of the default body is still there.
Should the mixed case produce the same error as the two-default case?
All reactions