Skip to content

Commit

Permalink
fix: mark map literals as experimental (#656)
Browse files Browse the repository at this point in the history
### 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>
  • Loading branch information
lars-reimann and megalinter-bot authored Oct 21, 2023
1 parent aafa2e3 commit ca47870
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
9 changes: 8 additions & 1 deletion src/language/validation/experimentalLanguageFeatures.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SdsIndexedAccess } from '../generated/ast.js';
import { SdsIndexedAccess, SdsMap } from '../generated/ast.js';
import { ValidationAcceptor } from 'langium';

export const CODE_EXPERIMENTAL_LANGUAGE_FEATURE = 'experimental/language-feature';
Expand All @@ -9,3 +9,10 @@ export const indexedAccessesShouldBeUsedWithCaution = (node: SdsIndexedAccess, a
code: CODE_EXPERIMENTAL_LANGUAGE_FEATURE,
});
};

export const mapsShouldBeUsedWithCaution = (node: SdsMap, accept: ValidationAcceptor): void => {
accept('warning', 'Map literals are experimental and may change without prior notice.', {
node,
code: CODE_EXPERIMENTAL_LANGUAGE_FEATURE,
});
};
3 changes: 2 additions & 1 deletion src/language/validation/safe-ds-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import {
lambdaMustBeAssignedToTypedParameter,
lambdaParameterMustNotHaveConstModifier,
} from './other/expressions/lambdas.js';
import { indexedAccessesShouldBeUsedWithCaution } from './experimentalLanguageFeatures.js';
import { indexedAccessesShouldBeUsedWithCaution, mapsShouldBeUsedWithCaution } from './experimentalLanguageFeatures.js';
import { requiredParameterMustNotBeExpert } from './builtins/expert.js';
import {
annotationCallArgumentsMustBeConstant,
Expand Down Expand Up @@ -197,6 +197,7 @@ export const registerValidationChecks = function (services: SafeDsServices) {
lambdaParametersMustNotBeAnnotated,
lambdaParameterMustNotHaveConstModifier,
],
SdsMap: [mapsShouldBeUsedWithCaution],
SdsMemberAccess: [
memberAccessMustBeNullSafeIfReceiverIsNullable(services),
memberAccessNullSafetyShouldBeNeeded(services),
Expand Down
7 changes: 0 additions & 7 deletions tests/resources/scoping/member accesses/skip-main.sdstest
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,6 @@ class SubClassForHiding sub SuperClassForHiding {
static fun staticMethodForHiding()
}

class ClassForResultMemberAccess() {
attr result: Int
}
enum EnumForResultMemberAccess {
result
}


// Access to own members -------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package tests.validation.experimentalLanguageFeature.maps

pipeline myPipeline {
// $TEST$ warning "Map literals are experimental and may change without prior notice."
»{"a": "b"}«;
}

0 comments on commit ca47870

Please sign in to comment.