aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr
diff options
context:
space:
mode:
authorpiegames <git@piegames.de>2024-07-13 05:24:41 +0200
committerpiegames <git@piegames.de>2024-08-17 19:47:51 +0200
commit49d61b2e4bf338042364c85d3c2ead0b33963e65 (patch)
tree09ffba6841df5a3990aa2d1c6bb9e19e0e355b14 /src/libexpr
parent1c080a8239f1be5a61d9fb2121ca958542ec183f (diff)
libexpr: Introduce Deprecated features
They are like experimental features, but opt-in instead of opt-out. They will allow us to gracefully remove language features. See #437 Change-Id: I9ca04cc48e6926750c4d622c2b229b25cc142c42
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/eval.cc17
-rw-r--r--src/libexpr/eval.hh15
-rw-r--r--src/libexpr/parser/parser.cc8
-rw-r--r--src/libexpr/parser/state.hh2
4 files changed, 30 insertions, 12 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 702b9b6ac..fcc28d1ca 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -2710,20 +2710,29 @@ Expr & EvalState::parseExprFromFile(const SourcePath & path, std::shared_ptr<Sta
}
-Expr & EvalState::parseExprFromString(std::string s_, const SourcePath & basePath, std::shared_ptr<StaticEnv> & staticEnv, const ExperimentalFeatureSettings & xpSettings)
+Expr & EvalState::parseExprFromString(
+ std::string s_,
+ const SourcePath & basePath,
+ std::shared_ptr<StaticEnv> & staticEnv,
+ const FeatureSettings & featureSettings
+)
{
// NOTE this method (and parseStdin) must take care to *fully copy* their input
// into their respective Pos::Origin until the parser stops overwriting its input
// data.
auto s = make_ref<std::string>(s_);
s_.append("\0\0", 2);
- return *parse(s_.data(), s_.size(), Pos::String{.source = s}, basePath, staticEnv, xpSettings);
+ return *parse(s_.data(), s_.size(), Pos::String{.source = s}, basePath, staticEnv, featureSettings);
}
-Expr & EvalState::parseExprFromString(std::string s, const SourcePath & basePath, const ExperimentalFeatureSettings & xpSettings)
+Expr & EvalState::parseExprFromString(
+ std::string s,
+ const SourcePath & basePath,
+ const FeatureSettings & featureSettings
+)
{
- return parseExprFromString(std::move(s), basePath, staticBaseEnv, xpSettings);
+ return parseExprFromString(std::move(s), basePath, staticBaseEnv, featureSettings);
}
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index ff45efc08..eab1f22ef 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -344,8 +344,17 @@ public:
/**
* Parse a Nix expression from the specified string.
*/
- Expr & parseExprFromString(std::string s, const SourcePath & basePath, std::shared_ptr<StaticEnv> & staticEnv, const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
- Expr & parseExprFromString(std::string s, const SourcePath & basePath, const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
+ Expr & parseExprFromString(
+ std::string s,
+ const SourcePath & basePath,
+ std::shared_ptr<StaticEnv> & staticEnv,
+ const FeatureSettings & xpSettings = featureSettings
+ );
+ Expr & parseExprFromString(
+ std::string s,
+ const SourcePath & basePath,
+ const FeatureSettings & xpSettings = featureSettings
+ );
Expr & parseStdin();
@@ -569,7 +578,7 @@ private:
Pos::Origin origin,
const SourcePath & basePath,
std::shared_ptr<StaticEnv> & staticEnv,
- const ExperimentalFeatureSettings & xpSettings = experimentalFeatureSettings);
+ const FeatureSettings & xpSettings = featureSettings);
/**
* Current Nix call stack depth, used with `max-call-depth` setting to throw stack overflow hopefully before we run out of system stack.
diff --git a/src/libexpr/parser/parser.cc b/src/libexpr/parser/parser.cc
index 6d496d141..e45776ca6 100644
--- a/src/libexpr/parser/parser.cc
+++ b/src/libexpr/parser/parser.cc
@@ -115,7 +115,7 @@ struct ExprState
std::unique_ptr<Expr> pipe(PosIdx pos, State & state, bool flip = false)
{
- if (!state.xpSettings.isEnabled(Xp::PipeOperator))
+ if (!state.featureSettings.isEnabled(Xp::PipeOperator))
throw ParseError({
.msg = HintFmt("Pipe operator is disabled"),
.pos = state.positions[pos]
@@ -656,7 +656,7 @@ template<> struct BuildAST<grammar::expr::path> : p::maybe_nothing {};
template<> struct BuildAST<grammar::expr::uri> {
static void apply(const auto & in, ExprState & s, State & ps) {
- bool noURLLiterals = ps.xpSettings.isEnabled(Xp::NoUrlLiterals);
+ bool noURLLiterals = ps.featureSettings.isEnabled(Xp::NoUrlLiterals);
if (noURLLiterals)
throw ParseError({
.msg = HintFmt("URL literals are disabled"),
@@ -858,7 +858,7 @@ Expr * EvalState::parse(
Pos::Origin origin,
const SourcePath & basePath,
std::shared_ptr<StaticEnv> & staticEnv,
- const ExperimentalFeatureSettings & xpSettings)
+ const FeatureSettings & featureSettings)
{
parser::State s = {
symbols,
@@ -866,7 +866,7 @@ Expr * EvalState::parse(
basePath,
positions.addOrigin(origin, length),
exprSymbols,
- xpSettings
+ featureSettings,
};
parser::ExprState x;
diff --git a/src/libexpr/parser/state.hh b/src/libexpr/parser/state.hh
index 30803a37e..9dddd28e1 100644
--- a/src/libexpr/parser/state.hh
+++ b/src/libexpr/parser/state.hh
@@ -19,7 +19,7 @@ struct State
SourcePath basePath;
PosTable::Origin origin;
const Expr::AstSymbols & s;
- const ExperimentalFeatureSettings & xpSettings;
+ const FeatureSettings & featureSettings;
void dupAttr(const AttrPath & attrPath, const PosIdx pos, const PosIdx prevPos);
void dupAttr(Symbol attr, const PosIdx pos, const PosIdx prevPos);