[Issue 20560] New: dom.d ctfe crashes compiler
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 5 02:02:35 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20560
Issue ID: 20560
Summary: dom.d ctfe crashes compiler
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: destructionator at gmail.com
import arsd.dom;
string translate(string xml) {
auto document = new Document(xml, true, true);
foreach(p; document.querySelectorAll("p"))
p.addClass("paragraph");
return document.toString();
}
enum e = translate("<xml><p>cool</p></xml>");
got segmentation fault when i try `dmd -c test.d` Specifically the `addClass`
method (among several other methods).
dom.d is here: https://github.com/adamdruppe/arsd/blob/master/dom.d
I haven't been able to reduce it more yet. The methods work on their own, e.g.
---
import arsd.dom;
string translate(string xml) {
auto e = new Element("test");
e.addClass("foo");
return e.toString;
}
enum e = translate("<xml><p>cool</p></xml>");
pragma(msg, e);
---
works fine. So I suspect the problem is actually because of me trying to work
with it in a deeper manner.
auto document = new Document(xml, true, true);
auto p = document.querySelector("p");
gave an error in a CTFE context
arsd/dom.d(7413): Error: variable relativeTo cannot be read at compile time
arsd/dom.d(7413): called from here: this.matchesElement(a, relativeTo)
/home/me/d/dmd2/linux/bin64/../../src/phobos/std/algorithm/iteration.d(1330):
called from here: __lambda3(this._input.front())
/home/me/d/dmd2/linux/bin64/../../src/phobos/std/algorithm/iteration.d(1356):
called from here: this.prime()
arsd/dom.d(1226): called from here: __r518.empty()
dam.d(6): called from here: document.querySelector("p")
dam.d(12): called from here: translate("<xml><p>cool</p></xml>")
dam.d(14): while evaluating pragma(msg, e)
and relativeTo is a regular local variable so this feels weird too. but
probably separate.
* * *
so back to the main thing
import arsd.dom;
string translate(string xml) {
auto document = new Document(xml, true, true);
auto p = document.querySelectorAll("p")[0];
return p.toString;
}
enum e = translate("<xml><p>cool</p></xml>");
that's fine. so it can apparently get the object.
idk what's going on just want to report anyway.
--
More information about the Digitalmars-d-bugs
mailing list