Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/org/perlonjava/core/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public final class Configuration {
* Automatically populated by Gradle/Maven during build.
* DO NOT EDIT MANUALLY - this value is replaced at build time.
*/
public static final String gitCommitId = "67da75215";
public static final String gitCommitId = "cf17bfaaa";

/**
* Git commit date of the build (ISO format: YYYY-MM-DD).
* Automatically populated by Gradle/Maven during build.
* DO NOT EDIT MANUALLY - this value is replaced at build time.
*/
public static final String gitCommitDate = "2026-03-19";
public static final String gitCommitDate = "2026-03-20";

// Prevent instantiation
private Configuration() {
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/org/perlonjava/frontend/parser/SubroutineParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,44 @@ static Node parseSubroutineCall(Parser parser, boolean isMethod) {
}
}

// Handle indirect object syntax with variable class: new $type $arg -> $type->new($arg)
// This is similar to the IDENTIFIER case above, but for variable class names
// Only applies when the subroutine doesn't exist (otherwise it's a function call)
if (!subExists && peek(parser).text.equals("$") && isValidIndirectMethod(subName) && !prototypeHasGlob) {
int currentIndex2 = parser.tokenIndex;
// Parse the variable that holds the class name
Node classVar = ParsePrimary.parsePrimary(parser);
if (classVar != null) {
LexerToken nextTok = peek(parser);
// Check this isn't actually a binary operator like $type + 1
if (!(nextTok.text.equals("->") || nextTok.text.equals("=>") || INFIX_OP.contains(nextTok.text))) {
// Parse arguments for the method call
ListNode arguments;
if (nextTok.text.equals(",") || nextTok.text.equals(";") ||
nextTok.text.equals(")") || nextTok.text.equals("}") ||
nextTok.type == LexerTokenType.EOF) {
// No arguments after class variable
arguments = new ListNode(currentIndex);
} else {
// Parse remaining arguments
arguments = consumeArgsWithPrototype(parser, "@");
}
// Create method call: $classVar->method(args)
return new BinaryOperatorNode(
"->",
classVar,
new BinaryOperatorNode("(",
new OperatorNode("&",
new IdentifierNode(subName, currentIndex2),
currentIndex),
arguments, currentIndex2),
currentIndex2);
}
// Not indirect object syntax - backtrack
parser.tokenIndex = currentIndex2;
}
}

// Create an identifier node for the subroutine name
IdentifierNode nameNode = new IdentifierNode(subName, parser.tokenIndex);

Expand Down
Loading