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

[scripts/splitSources.py] Add newline to files. #14062

Merged
merged 1 commit into from Apr 5, 2023

Conversation

aarlt
Copy link
Member

@aarlt aarlt commented Mar 21, 2023

Looks like we never had newlines in the splitted source files.

Copy link
Collaborator

@nikola-matic nikola-matic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? For debugging purposes in obscure cases?

@aarlt
Copy link
Member Author

aarlt commented Apr 5, 2023

This script is used in test/stopAfterParseTests.sh and scripts/ASTImportTest.sh. It's main purpose is to split some of our test-files into multiple files. E.g. these test-files can be found here: test/libsolidity/semanticTests/multiSource.

You can run this script locally by just running e.g. scripts/splitSources.py test/libsolidity/semanticTests/multiSource/free_different_interger_types.sol.

In this case we see two files that got splitted out from that multi-source test-file: s1.sol & s2.sol.

If you then just look at the content, you will see that there are no new-lines in this file.

$ cat s1.sol
function f(uint24) pure returns (uint) { return 24; }function g(bool) pure returns (bool) { return true; }

However, everything is working fine so far - by accident :P It is just working because we have only the comments at the end of the test-files.

E.g. if someone is adding a line comment (anywhere except at the end) within a multi-source test, it will create problems:

==== Source: s1.sol ====
// this is an awesome function
function f(uint24) pure returns (uint) { return 24; }
function g(bool) pure returns (bool) { return true; }
==== Source: s2.sol ====
import {f as g, g as g} from "s1.sol";
contract C {
  function foo() public pure returns (uint, bool) {
    return (g(2), g(false));
  }
}
// ====
// compileToEwasm: also
// ----
// foo() -> 24, true

Will then lead to:

$ cat s1.sol
// this is an awesome functionfunction f(uint24) pure returns (uint) { return 24; }function g(bool) pure returns (bool) { return true; }

Where the whole source code just becomes a single comment. I think we don't want to have this.

@nikola-matic nikola-matic merged commit 9e0a0af into develop Apr 5, 2023
@nikola-matic nikola-matic deleted the fix-split-sources-script branch April 5, 2023 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants