Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subprogram parameters are allowed as feature connection ends #1954

Closed
lwrage opened this issue Aug 19, 2019 · 5 comments
Closed

Subprogram parameters are allowed as feature connection ends #1954

lwrage opened this issue Aug 19, 2019 · 5 comments

Comments

@lwrage
Copy link
Contributor

lwrage commented Aug 19, 2019

Should not be allowed as no port, parameter, or access connections are allowed to connect to a parameter of a subprogram subcomponent.

@AaronGreenhouse
Copy link
Contributor

Looking at the spec, 9.1 (N1) says

A source or destination reference in a feature connection declaration must reference a feature declared in the component type, a feature in a feature group of the component type, or a feature of one of the subcomponents. The source and destination features must be abstract features, ports, parameters, access features, or feature groups.

(emphasis added)

I assume that this is not a general rule, but specifically a reference to the syntactic rule subprogram_call_identifier . feature_identifier in

feature_reference ::=
    -- feature in the component type component_type_feature_identifier |
    -- feature in a feature group of the component type component_type_feature_group_identifier . feature_identifier |

    -- feature in a subcomponent
    subcomponent_identifier . feature_identifier { . nested_feature_identifier }*
    
    -- feature in a call
    subprogram_call_identifier . feature_identifier 

In any case, this may be source the confusion in the implementation.

@AaronGreenhouse
Copy link
Contributor

AaronGreenhouse commented Sep 3, 2019

Test cases

package test
public
    
    thread th
        features
            ip: in data port;
            op: out data port;
            
            d1: requires data access;
            d2: requires data access;
    end th;
    
    thread implementation th.i
        subcomponents
            s1: subprogram s1;
        calls
            cs1: {
                call1: subprogram s1;
            	call2: subprogram s1;
            };
        connections
            ct1: parameter ip -> call1.p1; -- allowed
            ct2: parameter call1.p2 -> op; -- allowed
            
            bad1: port ip -> s1.p1; -- not allowed
            bad2: port s1.p2 -> op; -- not allowed
            
            bad10: parameter ip -> s1.p1; -- not allowed
            bad11: parameter s1.p2 -> op; -- not allowed
            
            f1: feature ip -> s1.p1; -- should not be allowed
            f2: feature s1.p2 -> op; -- should not be allowed
            
            f3: feature ip -> call1.p1; -- allowed
            f4: feature call1.p2 -> op; -- allowed
            
            dc1: parameter d1 -> call2.p1; -- allowed
            dc2: parameter call2.p2 -> d2; -- allowed
            
            bad20: data access d1 -> s1.p1; -- not allowed
            bad21: data access s1.p2 -> d2; -- not allowed
            
            f5: feature d1 -> s1.p1; -- should not be allowed
            f6: feature s1.p2 -> d2; -- should not be allowed
            
            f7: feature d1 -> call2.p1; -- allowed
            f8: feature call2.p2 -> d2;  -- allowed
    end th.i;
    
    subprogram s1
        features
            p1: in parameter;
            p2: out parameter;
    end s1;
end test;

Currently there are errors on

  • bad1 and bad2
  • bad10 and bad11
  • bad20 and bad21

There are no errors on

  • f1 and f2
  • f5 and f6

although there should be.

@AaronGreenhouse
Copy link
Contributor

Need to fix Aadl2JavaValidator.typeCheckFeatureConnectionEnd()

@AaronGreenhouse
Copy link
Contributor

Added test

			/*
			 * Issue 1954: features connections cannot reference parameter features as part of a subprogram subcomponent.
			 * They must be reference via subprogram call.
			 */
			if (connectionContext instanceof SubprogramSubcomponent && connectionEnd instanceof Parameter) {
				error(StringExtensions.toFirstUpper(getEClassDisplayNameWithIndefiniteArticle(connectionEnd.eClass()))
						+ " in " + getEClassDisplayNameWithIndefiniteArticle(connectionContext.eClass())
						+ " is not a valid feature connection end.", connectedElement,
						Aadl2Package.eINSTANCE.getConnectedElement_ConnectionEnd());
			}

to Aadl2JavaValidator.typeCheckFeatureConnectionEnd().

@lwrage
Copy link
Contributor Author

lwrage commented Sep 19, 2019

Fixed by PR #1983

@lwrage lwrage closed this as completed Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants