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

Standard libraries not working with general-newtypes=true #5345

Closed
MikaelMayer opened this issue Apr 22, 2024 · 1 comment · Fixed by #5347
Closed

Standard libraries not working with general-newtypes=true #5345

MikaelMayer opened this issue Apr 22, 2024 · 1 comment · Fixed by #5347
Labels
during 2: compilation of correct program Dafny rejects a valid program during compilation kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label priority: now Will work on this now

Comments

@MikaelMayer
Copy link
Member

Dafny version

latest-nightly

Code to produce this issue

# dfyconfig.toml

[options]
standard-libraries=true
type-system-refresh=true
general-newtypes=true

Command to run and resulting output

> dafny verify dfyconfig.toml

DafnyStandardLibraries.dfy(4398,14): Error: type conversion to a char type is al
lowed only from numeric and bitvector types, char, and ORDINAL (got bv6)
     |
4398 |       (i - 4) as char
     |               ^^

What happened?

There should have been no errors from the standard library.
This error is preventing me from using newtypes in my application that requires the standard library.

What type of operating system are you experiencing the problem on?

Windows

@MikaelMayer MikaelMayer added the kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label label Apr 22, 2024
@RustanLeino
Copy link
Collaborator

With --general-newtypes, the conversion has to go via int:

(i - 4) as int as char

@keyboardDrummer keyboardDrummer added during 2: compilation of correct program Dafny rejects a valid program during compilation priority: now Will work on this now labels Apr 23, 2024
MikaelMayer added a commit that referenced this issue Apr 30, 2024
This PR fixes the standard library so that it is compatible with general
newtypes.
Fixes #5345

### How has this been tested?
I added a verification test for just a small project with a dfyconfig
file including the standard library

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>

---------

Co-authored-by: Fabio Madge <fmadge@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
during 2: compilation of correct program Dafny rejects a valid program during compilation kind: bug Crashes, unsoundness, incorrect output, etc. If possible, add a `part:` label priority: now Will work on this now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants