wyvernlang / wyvern

The Wyvern programming language.
http://wyvernlang.github.io/
GNU General Public License v2.0
552 stars 65 forks source link

Effect declarations should be allowed anywhere in a module #354

Closed Darya- closed 4 years ago

Darya- commented 4 years ago

Currently, effect declarations are required to appear at the beginning of a module. However, it is useful to have them appear anywhere in the module (just like any other declaration can) because an effect declaration may use a module's field. If an effect isn't declared at the beginning of the module, the compiler throws an error saying that the module definition isn't a subtype of its declarated type. For example, in the text-editor application, if one adds an effect declaration to the TextEditor type and defines that declaration not at the beginning of the textEditor module, the compiler throws an error saying that textEditor isn't a subtype of TextEditor.

Darya- commented 4 years ago

To reproduce this issue, one could add the following line of code to the textEditor module (textEditor.wyv) after the fs field is defined:

effect Test = {fs.Read}