Skip to content

Regression in rdmd when running an empty eval #105

@mdparker

Description

@mdparker

deadalnix reported this on 2023-06-13T12:56:46Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=23989

CC List

  • alphaglosined
  • dlang-bugzilla
  • maxhaton

Description

We run unit tests for modules in the following way:

rdmd -m64 -Isrc -w -debug -g -unittest -i --extra-file=src/d/object.d --eval="/* Do nothing */"

With an extra-file per file. These command are generated automatically by the build and this used to work great.

With the latest rdmd, we have the following error message:

/tmp/.rdmd-1001/eval.73D1BDC8D7573E2DF9EF23CD86830110.d(18): Error: use { } for an empty statement, not ;
Failed: ["/usr/bin/dmd", "-m64", "-Isrc", "-w", "-debug", "-g", "-unittest", "-i", "-d", "-v", "-o-", "/tmp/.rdmd-1001/eval.73D1BDC8D7573E2DF9EF23CD86830110.d", "-I/tmp/.rdmd-1001"]
make: *** [src/libd.mak:33: check-libd-d] Error 1

This is because the generated file is as follow:

module temporary;
std.bigint, std.bitmanip,
std.compiler, std.complex, std.concurrency, std.container, std.conv,
std.csv,
std.datetime, std.demangle, std.digest.md, std.encoding, std.exception,
std.file,
std.format, std.functional, std.getopt, std.json,
std.math, std.mathspecial, std.mmfile,
std.numeric, std.outbuffer, std.parallelism, std.path, std.process,
std.random, std.range, std.regex, std.signals, std.socket,
std.stdint, std.stdio,
std.string, std.windows.syserror, std.system, std.traits, std.typecons,
std.typetuple, std.uni, std.uri, std.utf, std.variant, std.zip,

    std.zlib;
void main(char[][] args) {
/* Do nothing */;
}

Comments

alphaglosined commented on 2023-06-13T13:15:02Z

Not a regression in rdmd.

In dmd 2.104.0 empty statements with semicolons now error.

https://dlang.org/changelog/2.104.0.html#dmd.empty-statement-error

You do not need anything passed to the eval flag and it would not emit the semicolon.

However in saying that, rdmd in innerEvalCode should be made smarter so that it checks if last character is either a semicolon or a close brace, rather than just a semicolon. That way loops can work.

https://github.com/dlang/tools/blob/master/rdmd.d#L875

I suppose making it even smarter with comment detection ext. would be good too.

deadalnix commented on 2023-06-13T13:41:12Z

Something used to work.

Now it doesn't work.

None of the input provided contains either a {} or a ;, so clearly the the user supplied code isn't at fault.

If rdmd generates something that is now invalid, then this is rdmd's problem.

It's 100% a regression.

maxhaton commented on 2023-06-13T14:13:21Z

--eval containing a comment is pretty niche. Not entirely sure how to work around the empty statement problem. I assume it's to force evaluation because of the cache or something like that? If so then you might as well just s/rdmd/dmd because you basically gain 0 from rdmd other than it being slower.

rdmd does seem to have a test-suite though so we can add this to it.

dlang-bot commented on 2023-06-14T12:54:40Z

@RazvanN7 created dlang/tools pull request #460 "Fix Issue 23989 - Regression in rdmd when running an empty eval" fixing this issue:

  • Fix Issue 23989 - Regression in rdmd when running an empty eval

dlang/tools#460

dlang-bugzilla commented on 2023-06-14T14:50:39Z

(In reply to deadalnix from comment #0)

We run unit tests for modules in the following way:

Do you need a fix for this specific case? I don't think we can fix this general bug; we could add a hack that fixes this particular variation, but I think it only makes sense to do so if it helps someone in practice (see PR discussion).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions