Bug 9125 – mixin + textual import = order of declaration dependence

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-08T14:29:10Z
Last change time
2024-12-13T18:03:13Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Dmitry Olshansky
Moved to GitHub: dmd#18502 →

Attachments

IDFilenameSummaryContent-TypeSize
1166tables.dcode sample that gets mixed in text/plain135
1167mixin_order.dthe test case itselftext/plain298

Comments

Comment #0 by dmitry.olsh — 2012-12-08T14:29:10Z
Created attachment 1166 code sample that gets mixed in The test case are 2 files one is main and the other is being mixed in via import("tables.d"). command line: dmd -J. -c mixin_order.d dmd is 2.061 from github master. struct RleBitSet(T) { this(const(T)[] arr)const{ } } auto asSet(T)(in SetEntry!T e) { return RleBitSet!T(e.data); } //this way works //mixin(import("tables.d")); immutable NFCN = asSet(NFC_QCN); immutable NFCM = asSet(NFC_QCM); //this doesn't mixin(import("tables.d")); //------------------- // tables.d (also attached) //------------------- struct SetEntry(T) { T[] data; } immutable NFC_QCN = SetEntry!uint([1,2,3,4]); immutable NFC_QCM = SetEntry!uint([1,2,3,4]); It is expected that mixin(import("...")) makes code appear to be effectively pasted just there but obviously some processing step is missing as it doesn't work this way.
Comment #1 by dmitry.olsh — 2012-12-08T14:29:38Z
Created attachment 1167 the test case itself
Comment #2 by dmitry.olsh — 2013-10-20T06:15:20Z
Still fails with 2.064.
Comment #3 by dkorpel — 2018-12-04T14:04:49Z
Can be reduced to: ``` immutable int a = b; mixin("immutable int b = 3;"); ``` Output as of 2.083: Error: undefined identifier b It compiles when swapping the two lines or when removing the mixin and directly putting the declaration in the code.
Comment #4 by robert.schadek — 2024-12-13T18:03:13Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18502 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB