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

String concatenation in lang::java::m3::AST; #2089

Open
mike-uva opened this issue Dec 3, 2024 · 1 comment
Open

String concatenation in lang::java::m3::AST; #2089

mike-uva opened this issue Dec 3, 2024 · 1 comment
Labels

Comments

@mike-uva
Copy link

mike-uva commented Dec 3, 2024

Describe the bug
A concatenated string loses everything except for the first two parts.
To Reproduce
Define a string in Java:

String test = "Hello" + "beautiful" + "world";

Create an AST using lang::java::m3::Core and lang::java::m3::AST:

 M3 model = createM3FromMavenProject(projectLocation);
    list[Declaration] asts = [
        createAstFromFile(f, true)
        | f <- files(model.containment), isCompilationUnit(f)
    ];

Print the AST node containing the variable declaration statement.

Expected behavior
All parts of the string are present in the AST node.

Observed behavior
Only the first two parts of the string are present in the AST node.

declarationStatement(variables([],simpleType(id(\"String\")),[variable(id(\"test\"),[],plus(stringLiteral(\"\\\"Hello\\\"\"),stringLiteral(\"\\\"beautiful\\\"\")))]))
@mike-uva mike-uva added the bug label Dec 3, 2024
@Miljoen
Copy link

Miljoen commented Dec 13, 2024

There are quite some people that rely of this function as part of an ongoing university course, specifically an assignment on code clones.

By disregarding information past the second binary operator, this bug essentially yields invalid clones, preventing many to find the correct number of clones.

Many would be helped a lot if this issue gained priority, but regardless, I just wanted to let the Rascal team know why people are running into this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants