melt-umn / silver

An attribute grammar-based programming language for composable language extensions
http://melt.cs.umn.edu/silver/
GNU Lesser General Public License v3.0
58 stars 7 forks source link

Disallow multiple annotations with the same short name occuring on the same nonterminal #815

Open krame505 opened 10 months ago

krame505 commented 10 months ago

@remexre pointed out that if you have e.g. annotation foo::Integer; in grammar a and annotation foo::String in grammar b, you can have

nonterminal Thing with a:foo, b:foo;
production thing  top::Thing ::= {}

However, annotations get reduced to their short names in the function type, meaning you end up with multiple named parameters foo. This actually still sort of works - you can apply it as thing(foo=42, foo="hello"). However this is confusing, one would need to always qualify the annotation name when accessing it as t.a:foo or t.b:foo, and also the type expression syntax for named params seems to be broken with more than one named parameter.

Annotations can only occur on a nonterminal in the grammar of the nonterminal anyway - thus I vote we ban having multiple annotations with the same short name occuring on a nonterminal.