Skip to content
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

fix: mark map literals as experimental #656

Merged
merged 2 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"}«;
}