3958 – mixin(non-static method) crashes compiler

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3958 - mixin(non-static method) crashes compiler
Summary: mixin(non-static method) crashes compiler
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: All All
: P3 normal
Assignee: No Owner
URL: http://thecybershadow.net/
Keywords: ice-on-invalid-code, patch
Depends on:
Blocks:
Reported: 2010年03月13日 14:53 UTC by Vladimir Panteleev
Modified: 2014年02月15日 02:18 UTC (History)
3 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Vladimir Panteleev 2010年03月13日 14:53:46 UTC
struct S
{
	string g() { return ""; }
	void f() { mixin(g()); }
}
Making g() static stops DMD from crashing.
Comment 1 nfxjfg 2010年03月13日 14:58:02 UTC
There's another problem. This fails to compile:
struct S
{
 static string g() { return null; }
 void f() { mixin(g()); } //line 4
}
z.d(4): Error: argument to mixin must be a string, not (null)
(Tested with dmd v2.041.)
Comment 2 Don 2010年03月15日 12:21:05 UTC
PATCH(against 2.042): This is trivial.
// interpret.c line 2569:
 if (pthis && fd)
 { // Member function call
	if (pthis->op == TOKthis)
-	 pthis = istate->localThis;
+	 pthis = istate ? istate->localThis : NULL;
	else if (pthis->op == TOKcomma)
	 pthis = pthis->interpret(istate);
The second issue is that mixin(null); is never allowed. It's completely unrelated to this bug. Create a new bug for it if you think it matters.
Comment 3 Walter Bright 2010年03月28日 12:40:14 UTC
changeset 424
Comment 4 Don 2010年04月09日 13:38:29 UTC
Fixed DMD1.048 and 2.043.


AltStyle によって変換されたページ (->オリジナル) /