I am trying to implement a typesystem for my language. This worked so far for the simpler cases, but I am having some trouble with typing a construct that depends on the types of all of it's children, and there can be any amount of children ([0..n]). Each of the children can have one of three types: T1, T2 or T3<subtype1,subtype2,...>. I want to establish the following rules:
1: If any of the children have type T3, then the result is this type, and all other children with type T3 must have exactly the same subtypes.
2: if any of the children have type T2, then the result is T2, and none of the other children can have type T3
3: in all other cases, the result type is T1
The main problem I am facing is that the types of all the children have to be at least shallowly concrete before I can determine the return type, but there does not seem to be any language construct that does this. the "when concrete" syntax only allows for one node at a time, and nesting them is only possible if the amount of nodes is some predefined number. I am relatively new to MPS, so it is entirely possible that there is an obvious solution, but I am not seeing it.
Any help would be appreciated.