Bug 20368 – dmd 2.089.0 Error: expression `main` is `void` and has no value

Status
NEW
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-11-08T09:34:01Z
Last change time
2024-12-07T13:39:49Z
Keywords
pull
Assigned to
No Owner
Creator
Andrea Fontana
Moved to GitHub: dmd#17393 →

Comments

Comment #0 by trikkuz — 2019-11-08T09:34:01Z
// This worked on dmd <= 2.088.1 mixin Bug!"asd"; enum test; template Bug(string n) { int main() { import std; foreach(name; __traits(allMembers, __traits(parent, main))) static if (hasUDA!(__traits(getMember, __traits(parent, main), name), test)) return 0; return 0; } }
Comment #1 by trikkuz — 2019-11-08T09:37:28Z
Digger: digger: 36ccf092ed154a15700c2d082795bcc1ea1b8f99 is the first bad commit commit 36ccf092ed154a15700c2d082795bcc1ea1b8f99 Author: The Dlang Bot <[email protected]> Date: Mon Aug 26 12:33:40 2019 +0200 dmd: Merge pull request #10351 from JinShil/entry https://github.com/dlang/dmd/pull/10351 Move hard-coded logic to generate C main out of the compiler and into druntime merged-on-behalf-of: Nicholas Wilson <[email protected]> diff --git a/dmd b/dmd index 0de452558..a01aa5587 160000
Comment #2 by trikkuz — 2019-11-08T11:45:06Z
Reduced: module mymod; mixin Bug; template Bug() { void main() { import std; alias bug = hasUDA!(__traits(getMember, mymod, "main"), "myuda"); } }
Comment #3 by b2.temp — 2019-11-10T03:44:22Z
w/o phobos: --- module mymod; mixin Bug; mixin template Bug() { void main() { alias Attribs = __traits(getAttributes, __traits(getMember, mymod, "main")); } } ---
Comment #4 by slavo5150 — 2019-12-08T10:06:47Z
The `main` in `core/internal/entrypoint.d` and the `main` created by the user in their module results in an `OverloadSet`. When the user invokes `__traits(getMember, usersModule, "main")` the overload set is returned which evaluates to `void`. Working on a fix at https://github.com/dlang/druntime/pull/2861, but I'm not sure if it will work.
Comment #5 by dlang-bot — 2022-03-24T11:35:40Z
@MoonlightSentinel created dlang/druntime pull request #3786 "Fix 20368 - Remove name conflict for `main` mixin" fixing this issue: - Fix 20368 - Remove name conflict for `main` mixin Use a unique name with override mangle s.t. it doesn't conflict with the user-defined main. Co-authored-by: JinShil <[email protected]> Co-authored-by: Ernesto Castellotti <[email protected]> (see PR's 2861 and 2953) https://github.com/dlang/druntime/pull/3786
Comment #6 by robert.schadek — 2024-12-07T13:39:49Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17393 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB