uqbar-project / wollok

Wollok Programming Language
GNU General Public License v3.0
60 stars 16 forks source link

Change validation message adding "ClassX cannot be instantiated .. " #579

Closed javierfernandes closed 7 years ago

javierfernandes commented 8 years ago

This is for

Must implement inherited abstract methods: M1.doIt()" at "C"

Also replace

M1.doIt()

with

doIt() (required by M1)
fdodino commented 7 years ago

Ok, I added 4 different kind of errors:

"Class Lager cannot be instanciated. Must implement inherited abstract methods: fermentar(mosto) (required by Levadura)" at "Lager"
"Wrong definition of object anA. Must implement inherited abstract methods: A.blah()" at "anA"
"Class Quilmes cannot be instanciated. You must implement all methods: fermentar()" at "Quilmes"
"Wrong definition of object badWko. You must implement all methods: badWko.abstractMethod()" at "badWko"

Added 2 new tests for that.

npasserini commented 7 years ago

Hey, wkos should not allow for abstract methods!

2017-06-30 9:11 GMT-03:00 Fernando Dodino notifications@github.com:

Ok, I added 4 different kind of errors:

  • for a class inheriting from a superclass or mixed with some mixins
  • for a wko inheriting from a superclass or mixed with some mixins
  • for a bad defined class (which does not inherit from any superclass, but it defines an abstract method)
  • and also for a bad define wko (which does not inherit from any superclass, but it defines an abstract method)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/uqbar-project/wollok/issues/579#issuecomment-312251082, or mute the thread https://github.com/notifications/unsubscribe-auth/AEa1OeMkfIfUWtcirImODdVNW93iQ6O8ks5sJOXggaJpZM4HA1e- .

fdodino commented 7 years ago

I didn't follow you. I was talking about two different kind of errors,.and thus Messages 1) when you define an abstract method in a wko 2) when you inherit from an abstract class and you don't implement their abstract methods

I've done this already

npasserini commented 7 years ago

I mean, WKOs are different than classes. A class might have abstract methods, and then is abstract. A WKO can never have abstract methods.

So, if you have a class with abstract methods, you could only raise an error on instantiation, but if you have a WKO, you can mark the abstract method as an error immediately. I mean, not the object but the method itself. (I do not know if you already did so, sorry.)

Also, in the same line, I would make the message more specific. I understand current message is:

"Wrong definition of object badWko. You must implement all methods: badWko.abstractMethod()" at "badWko"

And instead could be something like (in method position)

"Abstract method not allowed here inside object definition, you must provide an implementation." at "method abstractMethod()"

2017-06-30 13:43 GMT-03:00 Fernando Dodino notifications@github.com:

I didn't follow you. I was talking about two different kind of errors,.and thus Messages

  1. when you define an abstract method in a wko
  2. when you inherit from an abstract class and you don't implement their abstract methods

I've done this already

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/uqbar-project/wollok/issues/579#issuecomment-312316701, or mute the thread https://github.com/notifications/unsubscribe-auth/AEa1OeFFGDNjOYmv3eO0bvfznX5rvgu_ks5sJSW6gaJpZM4HA1e- .

fdodino commented 7 years ago

It is ok if you want to change the message, I'll see how to change wko to method.

fdodino commented 7 years ago

Ok, @npasserini

I think I've finally got the point. When wko does not inherit from anything, behavior is

    abstractMethods.forEach [ abstractMethod |
        report('''«WollokDslValidator_WKO_WITHOUT_INHERITANCE_MUST_IMPLEMENT_ALL_METHODS»''',
            abstractMethod, WNAMED__NAME)
    ]

So, source of error is abstractMethod and not wko.

Messages are:

WollokDslValidator_WKO_MUST_IMPLEMENT_ABSTRACT_METHODS = You must implement all abstract methods inherited
WollokDslValidator_WKO_WITHOUT_INHERITANCE_MUST_IMPLEMENT_ALL_METHODS = Abstract method not allowed inside object definition, you must provide an implementation
npasserini commented 7 years ago

:-)

Yet, I think that "You must implement all inherited abstract methods" is better english than "You must implement all abstract methods inherited".

2017-06-30 20:22 GMT-03:00 Fernando Dodino notifications@github.com:

Ok, @npasserini https://github.com/npasserini

I think I've finally got the point. When wko does not inherit from anything, behavior is

          abstractMethods.forEach [ abstractMethod |
              report('''«WollokDslValidator_WKO_WITHOUT_INHERITANCE_MUST_IMPLEMENT_ALL_METHODS»''',
                  abstractMethod, WNAMED__NAME)
          ]

So, source of error is abstractMethod and not wko.

Messages are:

WollokDslValidator_WKO_MUST_IMPLEMENT_ABSTRACT_METHODS = You must implement all abstract methods inherited WollokDslValidator_WKO_WITHOUT_INHERITANCE_MUST_IMPLEMENT_ALL_METHODS = Abstract method not allowed inside object definition, you must provide an implementation

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/uqbar-project/wollok/issues/579#issuecomment-312392685, or mute the thread https://github.com/notifications/unsubscribe-auth/AEa1OR1yo-Gmkbap1_DBA1dCMjWZHii8ks5sJYMegaJpZM4HA1e- .

fdodino commented 7 years ago

Hahaha, are right you ! image