294 | | This check makes sure there are no '''!AnyValueOrNone''' assignments to "list" values (assignments to values within a template or value of a record of type). This currently covers references to local variables, formal parameters, component variables, return types of functions, and defined templates. |
295 | | |
296 | | {{{ |
297 | | TODO |
298 | | }}} |
| 294 | This check makes sure there are no '''!AnyValueOrNone''' assignments to "list" values (assignments to values within a template or value of a record of or set of type). This currently covers references to local variables, formal parameters, component variables, return types of functions, and defined templates. |
| 295 | |
| 296 | {{{ |
| 297 | type record MyListElement_Type { |
| 298 | integer x |
| 299 | //... |
| 300 | } |
| 301 | |
| 302 | type set MySetElement_Type { |
| 303 | integer x |
| 304 | //... |
| 305 | } |
| 306 | |
| 307 | type record of MyListElement_Type MyList_Type; |
| 308 | type set of MySetElement_Type MySet_Type; |
| 309 | |
| 310 | type component exampleComponent { |
| 311 | var template (omit) MyListElement_Type cv_MyListElement2 := {}; |
| 312 | var template (present) MyList_Type cv_MyList; |
| 313 | } |
| 314 | |
| 315 | function f_FunctionReturningElement1( |
| 316 | //.. |
| 317 | ) return template MyListElement_Type { |
| 318 | //... |
| 319 | } |
| 320 | |
| 321 | function f_Examples( |
| 322 | template MyListElement_Type p_MyListElement, |
| 323 | template(present) MyListElement_Type prp_MyListElement, |
| 324 | MyListElement_Type pv_MyListElement |
| 325 | ) runs on exampleComponent { |
| 326 | var MyListElement_Type v_MyListElement1 := {}; |
| 327 | var template (omit) MyListElement_Type v_MyListElement2 := {}; |
| 328 | var template (omit) MySetElement_Type v_MySetElement2 := {}; |
| 329 | var template (value) MyListElement_Type v_MyListElement3 := {}; |
| 330 | var template (present) MyListElement_Type v_MyListElement4 := {}; |
| 331 | var template MyListElement_Type v_MyListElement5 := {}; |
| 332 | var template (present) MyList_Type v_MyList; |
| 333 | var template (value) MyList_Type v_MyListV; |
| 334 | var template (present) MySet_Type v_MySet; |
| 335 | var integer i := 1; |
| 336 | v_MyList[i] := v_MyListElement1; // ok (SingleVarInstance) |
| 337 | v_MyList[i] := v_MyListElement2; // shall cause an error/warning |
| 338 | v_MyList[i] := cv_MyListElement2; // shall cause an error/warning |
| 339 | cv_MyList[i] := cv_MyListElement2; // shall cause an error/warning |
| 340 | cv_MyList[i] := v_MyListElement2; // shall cause an error/warning |
| 341 | v_MySet[i] := v_MySetElement2; // shall cause an error/warning |
| 342 | v_MyList[i] := v_MyListElement3; // ok (restriction=value) |
| 343 | v_MyList[i] := v_MyListElement3.x // ok (restriction=value) + field reference |
| 344 | v_MyList[i] := v_MyListElement4; // ok (restriction=present) |
| 345 | v_MyList[i] := v_MyListElement5; // shall cause an error/warning |
| 346 | v_MyList[i] := cr_MyListElement1; // shall cause an error/warning |
| 347 | v_MyList[i] := cr_MyListElement2; // ok (restriction=value) |
| 348 | v_MyList[i] := cr_MyListElement3(1) // ok (restriction=value) + paramters |
| 349 | v_MyList[i] := v_MyListV[1] // ok (restriction=value) + field reference |
| 350 | v_MyList[i] := valueof(cr_MyListElement3(1)) // ok (valueOf) |
| 351 | |
| 352 | v_MyList[i] := f_FunctionReturningElement1(); // shall cause an error/warning |
| 353 | //extra: parameters |
| 354 | v_MyList[i] := p_MyListElement; // shall cause an error/warning |
| 355 | v_MyList[i] := pv_MyListElement; // ok (FormalValuePar) |
| 356 | v_MyList[i] := prp_MyListElement; // ok (restriction=present) |
| 357 | //extra: direct |
| 358 | v_MyList[i] := omit; // shall cause an error/warning |
| 359 | v_MyList[i] := *; // shall cause an error/warning |
| 360 | } |
| 361 | |
| 362 | template (omit) MyListElement_Type cr_MyListElement1 := {}; |
| 363 | template (value) MyListElement_Type cr_MyListElement2 := {}; |
| 364 | template (value) MyListElement_Type cr_MyListElement3(integer p) := {}; |
| 365 | const MyListElement_Type ccr_MyListElement2 := {}; |
| 366 | |
| 367 | template (present) MyList_Type cr_MyList ( |
| 368 | MyListElement_Type p_Param1, // ok (FormalValuePar) |
| 369 | template (value) MyListElement_Type p_Param2, // ok (restriction=value) |
| 370 | template (omit) MyListElement_Type p_Param3, // shall cause an error/warning |
| 371 | template (present) MyListElement_Type p_Param4, // ok (restriction=present) |
| 372 | template MyListElement_Type p_Param5 // shall cause an error/warning |
| 373 | ) := { |
| 374 | //... |
| 375 | p_Param1, |
| 376 | //... |
| 377 | p_Param2, |
| 378 | //... |
| 379 | p_Param3, // shall cause an error |
| 380 | //... |
| 381 | p_Param4, |
| 382 | //... |
| 383 | {x:=p_Param2.x}, // ok, not directly assigned to list -> yes |
| 384 | //... |
| 385 | p_Param5, // shall cause an error |
| 386 | //... |
| 387 | cr_MyListElement1, // shall cause warning |
| 388 | //... |
| 389 | cr_MyListElement2, // ok (restriction=value) |
| 390 | //... |
| 391 | cr_MyListElement3(1), // ok (restriction=value) + parameters |
| 392 | //... |
| 393 | ccr_MyListElement2 // ok (constant) |
| 394 | }; |
| 395 | |
| 396 | function f_Extras() { |
| 397 | var template MyListElement_Type v_Element := *; |
| 398 | var template MyListElement_Type v_Element_e := {}; |
| 399 | var template (present) MyListElement_Type v_Element_p := {}; |
| 400 | var template MyList_Type v_List1 := { -, v_Element }; // shall cause an error/warning |
| 401 | var template MyList_Type v_List2 := { -, -, omit}; // shall cause an error/warning |
| 402 | var template MyList_Type v_List1 := { -, v_Element_e }; // shall cause an error/warning as well? |
| 403 | var template MyList_Type v_List1 := { -, v_Element_p }; // shall be fine? |
| 404 | // BUT |
| 405 | var template MyList_Type v_List3 := { cr_MyListElement2, * }; // is allowed i.e. shall not cause an error/warning |
| 406 | var template MyList_Type v_List3p := { cr_MyListElement3(1), * }; // is allowed i.e. shall not cause an error/warning |
| 407 | var template MyList_Type v_List4 := { * }; // is allowed too |
| 408 | v_List4[0] := * //shall still cause an error/warning |
| 409 | var template MyListElement_Type v_Element_r := v_Element_e; // should be ignored? |
| 410 | var template MyList_Type v_List1 := { -, v_Element_r }; // shall cause an error/warning as well? |
| 411 | // this is not checked as it is indirect |
| 412 | var template (present) MyListElement_Type v_Element_rp := v_Element_e; //should be ignored? or checked? |
| 413 | var template MyList_Type v_List1 := { -, v_Element_rp }; // shall cause an error/warning as well? |
| 414 | // -> not possible directly, |
| 415 | // -> in case earlier in the chain (above?) |
| 416 | //extra |
| 417 | var template (present) MyList_Type v_MyList; |
| 418 | var template (value) MyList_Type v_MyListV; |
| 419 | v_MyList := {}; // ok |
| 420 | v_MyList := {v_MyListV[1]}; // ok |
| 421 | |
| 422 | } |
| 423 | }}} |