-
Notifications
You must be signed in to change notification settings - Fork 75
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
Slang 0.18.3 #1056
Slang 0.18.3 #1056
Conversation
- update module resolution to NodeNext needed by slang - update all imports to slang to the latest one - update all import type to include the extension - TerminalNode#text is no longer available so we are using TerminalNode.unparse() instead. - renamed ABICoderPragma to AbicoderPragma
- using provided `asNonterminalNode` method instead of manually casting the tree. - using Parser instead of Language - some accessors became methods and some methods became accessors - using isNodeTerminal() since Node.type was removed - cst.children used to return Node[], now it returns Edge[]
…ettier/standalone to the developer
…rettier's version
@@ -23,18 +23,8 @@ const warnDeprecation = once(() => { | |||
return true; | |||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this PR is explicitly dropping support for v2, I wonder if this should be kept, specifying 3.0.0
instead?
Same question for src/slangPrinter.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prettier 2.2.X would still load the plugin and fail miserably when using it, so we needed the check for >=2.3.0
to show the reasons why it was failing.
Now prettier 2.X.X won't even load the plugin so the code will never reach this code.
there is a check in peerDependencies
in package.json
and I'll add this info on the readme.
tests/config/get-plugins.js
Outdated
const prettier = await getPrettier(); | ||
|
||
const prettierPath = path.dirname(require.resolve("prettier")); | ||
const pluginPrefix = satisfies(prettier.version, "^2.3.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remaining v2 support. I wonder if it should be removed?
Same question for src/common/backward-compatibility.js
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. thanks for finding this.
}); | ||
} | ||
|
||
test('should throw an error if there are incompatible ranges', function () { | ||
test.skip('should throw an error if there are incompatible ranges', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test is skipped. not sure if that was intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's intended to be skipped for now.
before we were joining pragma versions into a single string and it was straight forward to find an inconsistency, but as you pointed out, there are some edge cases where this approach leads to an error. Now we evaluate each pragma version against slang's supported versions, and now an incompatibility in the pragma versions is no different from an eager developer chasing to use the latest solidity release which might not be supported by slang just yet but with a syntax fully supported by slang.
so we might choose to remove this test as it might not be a responsibility of prettier-solidity
or we will have to add extra steps in the version inference to double check for the validity of the pragmas.
} | ||
|
||
function tryToCollectPragmas(text: string, version: string): string[] { | ||
const language = Parser.create(version); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion to remove the need for the extra dependency, and to be able to handle things like newlines/other corner cases:
const fileCursor = parser.parse(NonterminalKind.SourceUnit, source).createTreeCursor();
const values = [];
while (fileCursor.goToNextNonterminalWithKind(NonterminalKind.VersionExpressionSets)) {
const versionCursor = fileCursor.spawn();
let value = "";
while (versionCursor.goToNextTerminal()) {
const terminal = versionCursor.node.asTerminalNode()!;
if (TerminalKindExtensions.isTrivia(terminal.kind)) {
value += " "; // to break up any possible consecutive identifiers
} else {
value += terminal.unparse();
}
}
values.push(value);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried using this and tests aren't passing.
I suspect this is happening when there are no pragmas and the syntax is old.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That syntax node should be consistent across all Solidity versions:
https://nomicfoundation.github.io/slang/0.18.3/solidity-specification/01-file-structure/03-pragma-directives/#VersionExpressionSets
I wonder if you have a commit # I can try out? Happy to help if I can debug the failure..
@@ -1,18 +1,27 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we have integration tests that run this inside a browser?
I see that the README.md
says _Disabled during v2.0.0-beta_
. Is this correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were running all of our tests in a virtual empty javascript context. But had to drop it because it wouldn't load wasm
files and that configuration was design for commonjs
.
I'll research adding an integration test with a browser. karma
seems to be deprecated now.
I'll update the Readme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used puppeteer
before for CI testing, and IIRC, you can load an .html
in-memory and just query the elements there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few suggestions/question. Thank you! 🚀🚀
87a3d86
to
a1a6198
Compare
adding support for slang v0.18.0 and WebAssembly.
Main changes: