Skip to content

Commit

Permalink
fix: oversight with reconstruct for parameters in which only the valu…
Browse files Browse the repository at this point in the history
…e is of interest
  • Loading branch information
EagleoutIce committed Aug 5, 2023
1 parent 448ab8e commit cecffd1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/slicing/reconstruct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ function reconstructParameter(parameter: RParameter<ParentInformation>, name: Co

if(parameter.defaultValue !== undefined && name.length > 0) {
return plain(`${getLexeme(parameter.name)}=${getLexeme(parameter.defaultValue)}`)
} else if(parameter.defaultValue !== undefined && name.length === 0) {
return plain(getLexeme(parameter.defaultValue))
} else {
return name
}
Expand Down
4 changes: 2 additions & 2 deletions test/slicing/static/calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ a(x = 3)`
assertSliced('Must work for same named arguments too', shell, 'a <- 3\nb <- foo(a=a)', ['2@b'], 'a <- 3\nb <- foo(a=a)')

assertSliced('Must work for same named arguments nested', shell, `
f <- function(some_variable="hello") {
f <- function(some_variable="hello") {
result <- some::other(some_variable=some_variable)
result
result
}
`, ['4@result'], `function(some_variable="hello") {
result <- some::other(some_variable=some_variable)
Expand Down

0 comments on commit cecffd1

Please sign in to comment.