[Dlang-internal] With statement problems

Shigeki Karita shigekikarita at gmail.com
Sat Aug 25 05:52:13 UTC 2018


A with statement shows several counterintuitive results. I want 
to know that it is compiler bugs or spec defects.

- a with statement has higher priority than UFCS at inner scopes

this might conflict with 19.26.5 "When UFCS rewrite is necessary, 
compiler searches the name on accessible module level scope, in 
order from the innermost scope" and 11.19.1 "Within the with body 
the referenced object is searched first for identifier symbols"

- a with statement hides outer scope overloads

this might be bug. 11.19.6 says "In nested WithStatements, the 
inner-most scope takes precedence. If a symbol cannot be resolved 
at the inner-most scope, resolution is forwarded incrementally up 
the scope hierarchy." and 19.26.5 grantees compiler to find UFCS 
overload in outer scopes.

I made running example here
https://wandbox.org/permlink/gdnfyQyDewmOAzVi


related specs
https://docarchives.dlang.io/v2.081.0/spec/function.html#pseudo-member
https://docarchives.dlang.io/v2.081.0/spec/statement.html#with-statement



More information about the Dlang-internal mailing list