Skip to content

Dafny fails with most languages when using characters outside the BMP in string literals with --unicode-char:false #5737

Open
@ajewellamz

Description

@ajewellamz

Dafny version

4.7.0 (master as of 29 Aug, except for Rust which is latest feat_rust)

Code to produce this issue

module foo {
  method bar() {
    var decoded := "\uD835\uDFC1";
    var expected_redecoded := "𝟁";
    print decoded, "\n", expected_redecoded, "\n";
    print |decoded|, "\n", |expected_redecoded|, "\n";
    assert decoded == expected_redecoded;
    expect "\uD835\uDFC1" ==  "𝟁";
  }

  method Main() {
    print "Hello World!\n";
    bar();
  }
}

Command to run and resulting output

This command succeeds as expected :
dafny run -t cs --unicode-char:false foo.dfy

js also works correctly.

With a target of python or rust, we get weird runtime errors.

With java, it fails to run, for reasons that don't seem string related.

go mostly works, but prints `��` instead of `𝟁`

With cpp a compiler error "invalid universal character"

What happened?

I would expect all languages to behave as cs.

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

Mac

Metadata

Metadata

Assignees

No one assigned

    Labels

    during 4: bad execution of correct programA bug in the Dafny compiler that causes a correct Dafny program to execute incorrectlykind: bugCrashes, unsoundness, incorrect output, etc. If possible, add a `part:` labelpart: code-generationSupport for transpiling Dafny to another language. If relevant, add a `lang:` tag

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions