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

Regression in rdmd when running an empty eval #89

Open
mdparker opened this issue Jun 21, 2023 · 0 comments
Open

Regression in rdmd when running an empty eval #89

mdparker opened this issue Jun 21, 2023 · 0 comments

Comments

@mdparker
Copy link
Member

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant