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

Reconstructing sourced files ignores sourcing #822

Closed
Ellpeck opened this issue May 24, 2024 · 2 comments
Closed

Reconstructing sourced files ignores sourcing #822

Ellpeck opened this issue May 24, 2024 · 2 comments
Assignees
Labels
bug Something isn't working reconstruct code deals with the code reoncsutrction at the end of the static slicing static slicing Related to slicing the source code statically

Comments

@Ellpeck
Copy link
Member

Ellpeck commented May 24, 2024

The following tests contain an expected reconstruction string that is not what we expect, given the reconstruction should include code from the sourced files too - either inline or by including the source line in the reconstruction. Nevertheless, these tests pass.

const sources = {
	simple:   'N <- 9',
	closure1: 'f <- function() { function() 3 }',
	closure2: 'f <- function() { x <<- 3 }'
}
setSourceProvider(requestProviderFromText(sources))

// these are incorrect - where is the content from the sourced file?
assertSliced(label('simple source', ['name-normal', ...OperatorDatabase['<-'].capabilities, 'numbers', 'unnamed-arguments', 'strings', 'sourcing-external-files','newlines']),
	shell, 'source("simple")\ncat(N)', ['2@N'], 'N')
assertSliced(label('sourcing a closure', ['name-normal', ...OperatorDatabase['<-'].capabilities, 'sourcing-external-files', 'newlines', 'normal-definition', 'implicit-return', 'closures', 'numbers']),
	shell, 'source("closure1")\ng <- f()\nprint(g())', ['3@g'], 'g <- f()\ng()')
assertSliced(label('sourcing a closure w/ side effects', ['name-normal', ...OperatorDatabase['<-'].capabilities, 'sourcing-external-files', 'newlines', 'normal-definition', 'implicit-return', 'closures', 'numbers', ...OperatorDatabase['<<-'].capabilities]),
	shell, 'x <- 2\nsource("closure2")\nf()\nprint(x)', ['4@x'], 'f()\nx')

As can be seen from this last test, the sourced content is taken into account for the slice, however, as the x <- 2 line is not part of the expected outpout since x is redefined in f.

@Ellpeck Ellpeck added bug Something isn't working static slicing Related to slicing the source code statically reconstruct code deals with the code reoncsutrction at the end of the static slicing labels May 24, 2024
@EagleoutIce
Copy link
Member

Ok, so the dataflow graph is correct although we should add links to identify that all sourced nodes have a cd on the source call - can you make an issue for that @Ellpeck and get to it when you have the time?

Besides, actually updating the reconstruction to support this should be deferred to #484, allowing it to support the reconstruction of multiple files.

@EagleoutIce
Copy link
Member

Dealt with alongside #923.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reconstruct code deals with the code reoncsutrction at the end of the static slicing static slicing Related to slicing the source code statically
Projects
None yet
Development

No branches or pull requests

2 participants