Merge "libexpr: Soft-deprecate ancient let syntax" into main

This commit is contained in:
piegames 2024-08-21 11:22:48 +00:00 committed by Gerrit Code Review
commit e38410799b
5 changed files with 22 additions and 0 deletions

View file

@ -14,3 +14,4 @@ and can be disabled via the flags for backwards compatibility (opt-out with `--e
This means that all URLs must be properly put within quotes like all other strings. This means that all URLs must be properly put within quotes like all other strings.
- `rec-set-overrides`: **__overrides** is an old arcane syntax which has not been in use for more than a decade. - `rec-set-overrides`: **__overrides** is an old arcane syntax which has not been in use for more than a decade.
It is soft-deprecated with a warning only, with the plan to turn that into an error in a future release. It is soft-deprecated with a warning only, with the plan to turn that into an error in a future release.
- `ancient-let`: **The old `let` syntax** (`let { body = …; … }`) is soft-deprecated with a warning as well. Use the regular `let … in` instead.

View file

@ -668,6 +668,16 @@ template<> struct BuildAST<grammar::expr::uri> {
template<> struct BuildAST<grammar::expr::ancient_let> : change_head<BindingsState> { template<> struct BuildAST<grammar::expr::ancient_let> : change_head<BindingsState> {
static void success(const auto & in, BindingsState & b, ExprState & s, State & ps) { static void success(const auto & in, BindingsState & b, ExprState & s, State & ps) {
// Added 2024-09-18. Turn into an error at some point in the future.
// See the documentation on deprecated features for more details.
if (!ps.featureSettings.isEnabled(Dep::AncientLet))
warn(
"%s found at %s. This feature is deprecated and will be removed in the future. Use %s to silence this warning.",
"let {",
ps.positions[ps.at(in)],
"--extra-deprecated-features ancient-let"
);
b.attrs.pos = ps.at(in); b.attrs.pos = ps.at(in);
b.attrs.recursive = true; b.attrs.recursive = true;
s.pushExpr<ExprSelect>(b.attrs.pos, b.attrs.pos, std::make_unique<ExprAttrs>(std::move(b.attrs)), ps.s.body); s.pushExpr<ExprSelect>(b.attrs.pos, b.attrs.pos, std::make_unique<ExprAttrs>(std::move(b.attrs)), ps.s.body);

View file

@ -36,6 +36,15 @@ constexpr std::array<DeprecatedFeatureDetails, numDepFeatures> depFeatureDetails
Use fix point functions (e.g. `lib.fix` in Nixpkgs) instead. Use fix point functions (e.g. `lib.fix` in Nixpkgs) instead.
)", )",
}, },
{
.tag = Dep::AncientLet,
.name = "ancient-let",
.description = R"(
Allow the ancient `let { body = ; }` syntax.
Use the `let in` syntax instead.
)",
},
{ {
.tag = Dep::UrlLiterals, .tag = Dep::UrlLiterals,
.name = "url-literals", .name = "url-literals",

View file

@ -19,6 +19,7 @@ namespace nix {
enum struct DeprecatedFeature enum struct DeprecatedFeature
{ {
RecSetOverrides, RecSetOverrides,
AncientLet,
UrlLiterals, UrlLiterals,
}; };

View file

@ -0,0 +1 @@
--extra-deprecated-features ancient-let