Skip to content

Commit

Permalink
fix: mark map literals as experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-reimann committed Oct 21, 2023
1 parent aafa2e3 commit e3148da
Show file tree
Hide file tree
Showing 4 changed files with 19 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,
});
};
6 changes: 5 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,10 @@ 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 +200,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 e3148da

Please sign in to comment.