On Mon, 13 Jul 2015 08:53:18 GMT, Taylor Gronka wrote:
On Mon, 13 Jul 2015 08:01:08 GMT, Sönke Ludwig wrote:
Creating closures can sometimes indeed be tricky when nested scopes are involved, but I have troubles reproducing the errors above. What I have is this: http://dpaste.dzfl.pl/0804d5dbb52f
Is there anything structurally different from what you had?
I adapted your code snippet into a simple vibe project called test:
dub init test vibe.dIn dub.json, seems to be using vibe-d 0.7.19
Here is app.d
https://gist.github.com/gronka/f16b52641de6e481cabaI'm getting the same error when I try to compile
source/app.d(35): Error: need 'this' for 'm_pass' of type 'RequestPass'
Interesting, seems like this may be a compiler bug where it tries to create a function instead of a delegate. When using any explicit "delegate" syntax, it suddenly works:
HTTPServerRequestDelegate del = (req, res) => doRegister(req, res, m_pass);
router.get("/register", del);
router.get("/register", delegate (req, res) { doRegister(req, res, m_pass); });
Maybe partial
is the nicer syntax alternative, though.
Reduced case: http://dpaste.dzfl.pl/3d196916b8e3
Swapping the order of the two get
overloads also fixes the issue. I'll search the D bug tracker for an existing bug report later.