Bug 2827 – Crash compiling a foreach on an invalid class

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-04-10T00:54:00Z
Last change time
2015-06-09T01:18:03Z
Keywords
ice-on-invalid-code
Assigned to
bugzilla
Creator
bugs-d

Attachments

IDFilenameSummaryContent-TypeSize
3202827_still-semantic.diffCall semantic even when foreaching over invalid data.text/plain379

Comments

Comment #0 by bugs-d — 2009-04-10T00:54:20Z
When compiling the following code, DMD crashes (after issuing appropriate errors): --- import std.stdio; void main() { BadClass file; foreach (char[] line; file) writefln(line); } --- Not a huge issue, found when forgetting to import std.stream. Patch upcoming. -[Unknown]
Comment #1 by bugs-d — 2009-04-10T00:59:22Z
Created attachment 320 Call semantic even when foreaching over invalid data. This patch makes it still call semantic() on body, even if foreaching over an int or some such. This might cause additional noise ("undefined identifier line" here), but it makes it not crash and seems like the logical thing to do, according to usual convention when handling errors. DMD 1.x doesn't crash in this instance, because there's no nothrow involved. I would expect this patch would help DMD 1 too. -[Unknown]
Comment #2 by bugzilla — 2009-05-02T10:05:47Z
works dmd 2.029