Skip to content

Commit cb0ea0e

Browse files
committed
Requested Changes
1 parent c877ae8 commit cb0ea0e

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

liquidjava-verifier/src/main/java/liquidjava/rj_language/visitors/CreateASTVisitor.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,18 @@ private Expression functionCallCreate(FunctionCallContext rc) throws LJError {
187187
}
188188
}
189189

190+
/**
191+
* Handles both cases of dot calls: this.func(args) and targetFunc(this).func(args)
192+
* Converts them to func(this, args) and func(targetFunc(this), args) respectively
193+
*/
190194
private Expression dotCallCreate(DotCallContext rc) throws LJError {
191195
if (rc.OBJECT_TYPE() != null) {
192-
// this.func(args)
196+
197+
// check if there are multiple fields (e.g. this.a.b)
198+
if (rc.ID().size() > 1)
199+
throw new SyntaxError("Multiple dot notation is not allowed", rc.getText());
200+
201+
// this.func(args) => func(this, args)
193202
String text = rc.OBJECT_TYPE().getText();
194203
int dot = text.indexOf('.');
195204
String target = text.substring(0, dot);
@@ -205,7 +214,7 @@ private Expression dotCallCreate(DotCallContext rc) throws LJError {
205214
return new FunctionInvocation(name, args);
206215

207216
} else {
208-
// targetFunc(this).func(args)
217+
// targetFunc(this).func(args) => func(targetFunc(this), args)
209218
String targetFunc = rc.ID(0).getText();
210219
String func = rc.ID(1).getText();
211220
String name = Utils.qualifyName(prefix, func);

0 commit comments

Comments
 (0)