diff --git a/src/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.ts b/src/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.ts index b76617e058..0b3c40b5a0 100644 --- a/src/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.ts +++ b/src/r-bridge/lang-4.x/ast/parser/xml/internal/functions/argument.ts @@ -35,10 +35,11 @@ export function tryToNormalizeArgument(data: ParserData, objs: NamedXmlBasedJson if(symbolOrExpr.name === RawRType.Expression) { name = undefined parsedValue = tryNormalizeSingleNode(data, symbolOrExpr) - } else if(symbolOrExpr.name === RawRType.SymbolSub) { + } else if(symbolOrExpr.name === RawRType.SymbolSub || symbolOrExpr.name === RawRType.StringConst) { name = { type: RType.Symbol, - location, content, + location, + content: symbolOrExpr.name === RawRType.StringConst ? content.slice(1,-1) : content, namespace: undefined, lexeme: content, info: { diff --git a/test/functionality/r-bridge/lang/ast/parse-function-call.ts b/test/functionality/r-bridge/lang/ast/parse-function-call.ts index 6dfe19e5a0..e05a807f12 100644 --- a/test/functionality/r-bridge/lang/ast/parse-function-call.ts +++ b/test/functionality/r-bridge/lang/ast/parse-function-call.ts @@ -169,6 +169,71 @@ describe('Parse function calls', withShell((shell) => { ], }) ) + const code = 'f("a"=3,\'x\'=2)' + assertAst( + `string arguments - ${code}`, + shell, + code, + exprList({ + type: RType.FunctionCall, + flavor: 'named', + location: rangeFrom(1, 1, 1, 1), + lexeme: 'f', + info: {}, + functionName: { + type: RType.Symbol, + location: rangeFrom(1, 1, 1, 1), + lexeme: 'f', + content: 'f', + namespace: undefined, + info: {} + }, + arguments: [ + { + type: RType.Argument, + location: rangeFrom(1, 3, 1, 5), + name: { + type: RType.Symbol, + location: rangeFrom(1, 3, 1, 5), + lexeme: '"a"', + content: 'a', + namespace: undefined, + info: {} + }, + lexeme: '"a"', + info: {}, + value: { + type: RType.Number, + location: rangeFrom(1, 7, 1, 7), + lexeme: '3', + content: numVal(3), + info: {} + } + }, + { + type: RType.Argument, + location: rangeFrom(1, 9, 1, 11), + name: { + type: RType.Symbol, + location: rangeFrom(1, 9, 1, 11), + lexeme: '\'x\'', + content: 'x', + namespace: undefined, + info: {} + }, + lexeme: '\'x\'', + info: {}, + value: { + type: RType.Number, + location: rangeFrom(1, 13, 1, 13), + lexeme: '2', + content: numVal(2), + info: {} + } + } + ], + }) + ) }) describe('directly called functions', () => { assertAst(