Skip to content

Commit 67a58e4

Browse files
Geod24WebFreak001
authored andcommitted
settings/selections: Only warn on unknown keys, add changelog
This will give users the time to adapt, without erroring right away.
1 parent 9a034ec commit 67a58e4

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

changelog/configy_stricter_parsing.dd

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
dub will now warn on unrecognized settings or selections file
2+
3+
Previously, dub was silently accepting anything it didn't recognize
4+
in `[dub.]settings.json` and `dub.selections.json`. While the original
5+
intent was to make forward-compatibility easy, it proved detrimental
6+
as typos would just mean the user setting was ignored.
7+
8+
From this release, dub will now warn about any entry in its configuration files
9+
or in `dub.selections.json`. After 10 releases, those warnings will turn into errors.

source/dub/dub.d

+4-1
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,13 @@ class Dub {
267267

268268
void readSettingsFile (NativePath path_)
269269
{
270+
// TODO: Remove `StrictMode.Warn` after v1.40 release
271+
// The default is to error, but as the previous parser wasn't
272+
// complaining, we should first warn the user.
270273
const path = path_.toNativeString();
271274
if (path.exists)
272275
this.m_config = this.m_config.merge(
273-
parseConfigFile!UserConfiguration(CLIArgs(path)));
276+
parseConfigFile!UserConfiguration(CLIArgs(path), StrictMode.Warn));
274277
}
275278

276279
const dubFolderPath = NativePath(thisExePath).parentPath;

source/dub/project.d

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ class Project {
7979

8080
auto selverfile = (m_rootPackage.path ~ SelectedVersions.defaultFile).toNativeString();
8181
if (existsFile(selverfile)) {
82-
auto selected = parseConfigFileSimple!Selected(selverfile);
82+
// TODO: Remove `StrictMode.Warn` after v1.40 release
83+
// The default is to error, but as the previous parser wasn't
84+
// complaining, we should first warn the user.
85+
auto selected = parseConfigFileSimple!Selected(selverfile, StrictMode.Warn);
8386
enforce(!selected.isNull(), "Could not read '" ~ selverfile ~ "'");
8487
m_selections = new SelectedVersions(selected.get());
8588
} else m_selections = new SelectedVersions;

0 commit comments

Comments
 (0)