Skip to content

Commit ca47870

Browse files
fix: mark map literals as experimental (#656)
### Summary of Changes Our map literals are fairly new and need to be tested for some time. Because of this, they are now marked as experimental. --------- Co-authored-by: megalinter-bot <129584137+megalinter-bot@users.noreply.github.com>
1 parent aafa2e3 commit ca47870

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

src/language/validation/experimentalLanguageFeatures.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SdsIndexedAccess } from '../generated/ast.js';
1+
import { SdsIndexedAccess, SdsMap } from '../generated/ast.js';
22
import { ValidationAcceptor } from 'langium';
33

44
export const CODE_EXPERIMENTAL_LANGUAGE_FEATURE = 'experimental/language-feature';
@@ -9,3 +9,10 @@ export const indexedAccessesShouldBeUsedWithCaution = (node: SdsIndexedAccess, a
99
code: CODE_EXPERIMENTAL_LANGUAGE_FEATURE,
1010
});
1111
};
12+
13+
export const mapsShouldBeUsedWithCaution = (node: SdsMap, accept: ValidationAcceptor): void => {
14+
accept('warning', 'Map literals are experimental and may change without prior notice.', {
15+
node,
16+
code: CODE_EXPERIMENTAL_LANGUAGE_FEATURE,
17+
});
18+
};

src/language/validation/safe-ds-validator.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ import {
9090
lambdaMustBeAssignedToTypedParameter,
9191
lambdaParameterMustNotHaveConstModifier,
9292
} from './other/expressions/lambdas.js';
93-
import { indexedAccessesShouldBeUsedWithCaution } from './experimentalLanguageFeatures.js';
93+
import { indexedAccessesShouldBeUsedWithCaution, mapsShouldBeUsedWithCaution } from './experimentalLanguageFeatures.js';
9494
import { requiredParameterMustNotBeExpert } from './builtins/expert.js';
9595
import {
9696
annotationCallArgumentsMustBeConstant,
@@ -197,6 +197,7 @@ export const registerValidationChecks = function (services: SafeDsServices) {
197197
lambdaParametersMustNotBeAnnotated,
198198
lambdaParameterMustNotHaveConstModifier,
199199
],
200+
SdsMap: [mapsShouldBeUsedWithCaution],
200201
SdsMemberAccess: [
201202
memberAccessMustBeNullSafeIfReceiverIsNullable(services),
202203
memberAccessNullSafetyShouldBeNeeded(services),

tests/resources/scoping/member accesses/skip-main.sdstest

-7
Original file line numberDiff line numberDiff line change
@@ -500,13 +500,6 @@ class SubClassForHiding sub SuperClassForHiding {
500500
static fun staticMethodForHiding()
501501
}
502502

503-
class ClassForResultMemberAccess() {
504-
attr result: Int
505-
}
506-
enum EnumForResultMemberAccess {
507-
result
508-
}
509-
510503

511504
// Access to own members -------------------------------------------------------
512505

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package tests.validation.experimentalLanguageFeature.maps
2+
3+
pipeline myPipeline {
4+
// $TEST$ warning "Map literals are experimental and may change without prior notice."
5+
»{"a": "b"}«;
6+
}

0 commit comments

Comments
 (0)