From 3dbf68f78caab17d64621dc3b204d23eabbfa45c Mon Sep 17 00:00:00 2001 From: Mikael Mayer Date: Wed, 22 Jan 2025 13:06:23 -0600 Subject: [PATCH 1/4] Chore: Support for `--do-boogie-translation` And not activated by default if `--no-verify` is set. This option emulates the `/dafnyVerify` command in the previous CLI Added tests --- Source/DafnyCore/Options/BoogieOptionBag.cs | 14 +++- Source/DafnyCore/Options/DafnyCommands.cs | 1 + Source/DafnyDriver.Test/OptionsTest.cs | 72 +++++++++++++++++++++ Source/DafnyDriver/Commands/RunCommand.cs | 6 +- Source/DafnyDriver/DafnyNewCli.cs | 6 +- Source/DafnyDriver/WritersConsole.cs | 2 +- docs/DafnyRef/UserGuide.md | 2 + 7 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 Source/DafnyDriver.Test/OptionsTest.cs diff --git a/Source/DafnyCore/Options/BoogieOptionBag.cs b/Source/DafnyCore/Options/BoogieOptionBag.cs index 59ffe8bfcbe..4d7a1302fef 100644 --- a/Source/DafnyCore/Options/BoogieOptionBag.cs +++ b/Source/DafnyCore/Options/BoogieOptionBag.cs @@ -46,6 +46,8 @@ public static class BoogieOptionBag { public static readonly Option NoVerify = new("--no-verify", "Skip verification"); + public static readonly Option DoBoogieTranslation = new("--do-boogie-translation", "Requires --no-verify. Does translation to Boogie but Boogie won't verify it."); + public static readonly Option HiddenNoVerify = new("--hidden-no-verify", "Allows building unverified libraries without recording that they were not verified.") { IsHidden = true @@ -107,9 +109,14 @@ static BoogieOptionBag() { }); DafnyOptions.RegisterLegacyBinding(Cores, (o, f) => o.VcsCores = f == 0 ? (1 + System.Environment.ProcessorCount) / 2 : (int)f); - DafnyOptions.RegisterLegacyBinding(NoVerify, (options, value) => { - var shouldVerify = !value && !options.Get(HiddenNoVerify); - options.Verify = shouldVerify; + DafnyOptions.RegisterLegacyBinding(NoVerify, (options, dotNotVerify) => { + var shouldVerify = !dotNotVerify && !options.Get(HiddenNoVerify); + options.Verify = shouldVerify; // Boogie won't verify + }); + // Previously /dafnyVerify + DafnyOptions.RegisterLegacyBinding(DoBoogieTranslation, (options, doBoogieTranslation) => { + options.DafnyVerify = (!options.Get(NoVerify) && !options.Get(HiddenNoVerify)) + || doBoogieTranslation || options.Get(DeveloperOptionBag.BoogiePrint) != null; // Dafny won't translate the code to Boogie }); DafnyOptions.RegisterLegacyBinding(VerificationTimeLimit, (o, f) => o.TimeLimit = f); @@ -144,6 +151,7 @@ static BoogieOptionBag() { OptionRegistry.RegisterGlobalOption(BoogieArguments, OptionCompatibility.CheckOptionMatches); OptionRegistry.RegisterGlobalOption(NoVerify, OptionCompatibility.OptionLibraryImpliesLocalError); + OptionRegistry.RegisterGlobalOption(DoBoogieTranslation, OptionCompatibility.OptionLibraryImpliesLocalError); OptionRegistry.RegisterOption(HiddenNoVerify, OptionScope.Cli); OptionRegistry.RegisterOption(Cores, OptionScope.Cli); OptionRegistry.RegisterOption(VerificationTimeLimit, OptionScope.Cli); diff --git a/Source/DafnyCore/Options/DafnyCommands.cs b/Source/DafnyCore/Options/DafnyCommands.cs index 3f8c281c9ce..6dee61a1c40 100644 --- a/Source/DafnyCore/Options/DafnyCommands.cs +++ b/Source/DafnyCore/Options/DafnyCommands.cs @@ -52,6 +52,7 @@ static DafnyCommands() { public static readonly IReadOnlyList