Skip to content

Commit 44a48ea

Browse files
Jantherfvictorio
andauthored
Infer version (#1047)
* update dependencies * Adding the compiler inference logic * upgrading tests for version inferrence * Since importing maxSatisfying and minSatisfying, there is no benefit in importing semver functionality by independent functions. * fixing bug in VersionLiteral * using string replace to remove all comments from the VersionExpressionSets * Move inferLanguage to its own module * Add tests for inferLanguage * added extra test case * check if there is at least 1 valid version in the ranges before comparing it against the supported versions. * adding more specific tests * validating a range like `0.5.0 - 0.6.0` gets rewritten to comparators `>=0.5.0 <=0.6.0` which can be concatenated. * refactor test * Add test case for infer-language --------- Co-authored-by: Franco Victorio <[email protected]>
1 parent 3551102 commit 44a48ea

File tree

55 files changed

+441
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+441
-263
lines changed

jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ if (TEST_STANDALONE) {
88
);
99
} else {
1010
testMatch.push('<rootDir>/tests/unit/**/*.test.js');
11+
testMatch.push('<rootDir>/tests/unit/**/*.test.ts');
1112
}
1213

1314
export default {

package-lock.json

Lines changed: 92 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,13 @@
7575
},
7676
"devDependencies": {
7777
"@babel/code-frame": "^7.24.7",
78+
"@types/jest": "^29.5.13",
7879
"@types/semver": "^7.5.8",
79-
"@typescript-eslint/eslint-plugin": "^8.6.0",
80-
"@typescript-eslint/parser": "^8.6.0",
80+
"@typescript-eslint/eslint-plugin": "^8.7.0",
81+
"@typescript-eslint/parser": "^8.7.0",
8182
"c8": "^9.1.0",
8283
"cross-env": "^7.0.3",
83-
"eslint": "^9.10.0",
84+
"eslint": "^9.11.1",
8485
"eslint-config-prettier": "^9.1.0",
8586
"esm-utils": "^4.3.0",
8687
"esmock": "^2.6.7",
@@ -96,7 +97,7 @@
9697
"ts-loader": "^9.5.1",
9798
"ts-node": "^10.9.2",
9899
"typescript": "^5.5.4",
99-
"webpack": "^5.94.0",
100+
"webpack": "^5.95.0",
100101
"webpack-cli": "^5.1.4"
101102
},
102103
"dependencies": {

src/slang-nodes/ContractDefinition.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { doc } from 'prettier';
2-
import coerce from 'semver/functions/coerce.js';
3-
import satisfies from 'semver/functions/satisfies.js';
2+
import { coerce, satisfies } from 'semver';
43
import { NonterminalKind } from '@nomicfoundation/slang/kinds/index.js';
54
import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js';
65
import { Identifier } from './Identifier.js';

src/slang-nodes/FunctionDefinition.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import coerce from 'semver/functions/coerce.js';
2-
import satisfies from 'semver/functions/satisfies.js';
1+
import { coerce, satisfies } from 'semver';
32
import { NonterminalKind } from '@nomicfoundation/slang/kinds/index.js';
43
import { printFunction } from '../slang-printers/print-function.js';
54
import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js';

src/slang-nodes/ImportDeconstructionSymbols.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { doc } from 'prettier';
2-
import coerce from 'semver/functions/coerce.js';
3-
import satisfies from 'semver/functions/satisfies.js';
2+
import { coerce, satisfies } from 'semver';
43
import { NonterminalKind } from '@nomicfoundation/slang/kinds/index.js';
54
import { printSeparatedList } from '../slang-printers/print-separated-list.js';
65
import { getNodeMetadata, updateMetadata } from '../slang-utils/metadata.js';

src/slang-nodes/VersionLiteral.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ export class VersionLiteral implements SlangNode {
3535
}
3636

3737
print(path: AstPath<VersionLiteral>, print: PrintFunction): Doc {
38-
return path.call(print, 'variant');
38+
return typeof this.variant === 'string'
39+
? this.variant
40+
: path.call(print, 'variant');
3941
}
4042
}

0 commit comments

Comments
 (0)