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
59 stars 7 forks source link

Flow analysis confuses attributes from separate grammars when imported together #488

Open RandomActsOfGrammar opened 3 years ago

RandomActsOfGrammar commented 3 years ago

I have four grammars: common, A, B, and main. Both A and B import common, and main imports all three.

The grammar common defines several nonterminals and productions shared between A and B. Both A and B define a synthesized attribute named translation, both of which occur on these shared nonterminals. In A, the translation depends on some attributes which only occur in A. There are no flow errors in either A or B alone.

When I compile the main grammar, I get flow errors in B for accessing B's translation attribute without giving the inherited attributes necessary for A's translation attribute. It doesn't matter which grammar is imported first.

krame505 commented 3 years ago

Interesting. What happens if you specify the flow types for the translation attributes explicitly? Curious if this is a bug with flow type inference or lookup.

krame505 commented 3 years ago

Also, do you have a minimal example somewhere that reproduces this?

RandomActsOfGrammar commented 3 years ago

If I specify the flow types, the errors are reduced to a single error for exceeding the flow type.

I'm not having any luck creating a minimal example. My attempts thus far have not given errors.