rascal
rascal copied to clipboard
Keyword arguments at function/constructor call sites do not appear as use in TModel
Describe the bug
- [ ] Keyword arguments at function/constructor call sites do not appear as use in TModel.
- [ ] Use/defs of keyword arguments at
d.foorefer to the full ADT definition, instead of the field definition.
To Reproduce
void functionKeywordFormal() {
println("== Keyword formals (functions) ===");
tm = typeCheck(
"int f(int foo, int bar = 1) = foo + bar;
'int g() = f(1, bar = 2);");
defs = {d.defined | Define d:<_, _, _, keywordFormalId(), _, _> <- tm.defines};
uses = invert(tm.useDef)[defs];
print("Defs - of role `keywordFormalId()`: ");
iprintln(defs);
println("`f(...)` call site: <invert(tm.useDef)[(tm.defines<idRole, defined>)[functionId()]]>");
// No use at the line of the function call, although the keyword argument is used there
print("Uses - of role `keywordFormalId()`: ");
iprintln(uses);
println("======================\n");
}
void dataKeywordFormal() {
println("== Keyword formals (ADTs) ===");
tm = typeCheck(
"data D(int foo = 1) = d(int bar = 2);
'D f() = d(foo = 8, bar = 54);");
print("Defs - of keyword arguments: ");
defs = {<d, role> | <d, role> <- (tm.defines<idRole, defined, idRole>)[{keywordFieldId(), keywordFormalId()}]};
iprintln(defs);
// No use at the line of the constructor call, although the keyword arguments are used there
uses = tm.useDef o defs;
print("Uses - of above definitions: ");
iprintln(uses);
println("======================\n");
}
Expected behavior Uses to exist.