[Dlang-internal] With statement problems

Mike Franklin slavo5150 at yahoo.com
Sun Aug 26 05:48:30 UTC 2018


On Saturday, 25 August 2018 at 05:52:13 UTC, Shigeki Karita wrote:
> 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

I'm not seeing the problem you're trying to illustrate.  IMO, if 
there is an ambiguity, the symbol with the most local scope 
should take precedence.  If there is an ambiguity with types, the 
symbol with the most specific type should take precedence.

Can you create an example that shows the above not happening?

Mike


More information about the Dlang-internal mailing list