Closed jvasileff closed 8 years ago
Actually, it looks like we just don’t support value constructors at all – I seem to have completely forgotten that. Whoops :)
Spec:
CallableConstructorHeader: "new" MemberName? Parameters ExtendedType?
ValueConstructorHeader: "new" MemberName ExtendedType?
I thought about just making ConstructorDefinition
’s parameters
optional, but then we can’t encode the requirement that a value constructor must have a name, so it’s probably better to have separate classes: rename ConstructorDefinition
to CallableConstructorDefinition
, add abstract superclass ConstructorDefinition
, add subclass ValueConstructorDefinition
. Objections?
That sounds reasonable to me. The only counter arguments I can come up with are:
LazySpecification
is used for both functions and values, so just having one class would be parallel.1.2.0
:smile: the optional parameters approach would result in a less jarring compatibility change, if that even matters.But overall, I think I agree that having name
for values be non-null is the better approach.
If you'll consider issuing patch releases for 1.2.0
That’s the plan, yes, to put this in a 1.2.1
or something.
(note to self: don’t forget to do this in a branch based on 1.2.0
, rather than master
.)
Done in branch addValueConstructorDefinition
. @jvasileff can you try it out before I push the merge to master
? (Also cc @Vorlent, this should fix your problem from Dec 6th.)
Well, I tried to run the Dart backend with ceylon.ast
on addValueConstructorDefinition
… and I can confirm that the reported bug no longer occurs. Instead, it naturally blows up with an error that transformValueConstructorDefinition
isn’t implemented in captureVisitor
.
I’ll merge it into master, since it looks mostly good to me.
Thanks @lucaswerkmeister, that was still on my todo list.
naturally blows up with an error
that's not natural, it's horrible!
BTW, with the latest couple fixes, we've got to be close to 100% coverage for real world testing. It's amazing how well ceylon.ast has worked out!
that's not natural, it's horrible!
well I added a method to the interface and then ran your compiler again without recompiling it – what else could possibly have happened? I’m not sure how I didn’t realize this would happen before I tried it out.
Yeah, it's not all that unexpected. But my aim has been to provide nice compiler error messages with column and line number info for unsupported features.
edit: never mind :smile:
Attempting to convert
results in
the Redhat AST is: