Comment #0 by destructionator — 2020-02-05T02:02:35Z
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.
Comment #1 by robert.schadek — 2024-12-13T19:07:00Z