[Issue 7372] Error provides too little information to diagnose the problem (error: undefined identifier)

2022-09-05 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=7372

Dlang Bot  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Dlang Bot  ---
dlang/dmd pull request #14420 "Add supplemental scope info to mixin T; errors -
Fix issue 7372 - Error provides too little information to diagnose the problem
(error: undefined identifier)" was merged into master:

- 158c37c76ec15b0bb30866e1557cef936d614d5d by WebFreak001:
  Add supplemental scope info to mixin T; errors

  Fix issue 7372 - Error provides too little information to diagnose the
problem (error: undefined identifier)

  Mixin templates are often defined inside libraries and may require the
  definition of certain symbols alongside them (for example a text
  templating library mapping struct fields to HTML text blocks could
  attempt to simply access member variables) - Fixing compilation errors
  where such identifiers are not found would then usually not require
  code changes inside the library, but rather in the user code, where the
  mixin is written.

  So this PR adds a supplemental `parent scope from here: '...'` message,
  which may be used from IDEs to show errors on the mixin line or just for
  the user to read it in the command line and see where in the user code
  the error originates from.

https://github.com/dlang/dmd/pull/14420

--


[Issue 7372] Error provides too little information to diagnose the problem (error: undefined identifier)

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7372


Leandro Lucarella leandro.lucare...@sociomantic.com changed:

   What|Removed |Added

   Keywords|rejects-valid   |diagnostic
 Status|RESOLVED|REOPENED
 Resolution|INVALID |
Summary|(Regression git) wrong  |Error provides too little
   |error: undefined identifier |information to diagnose the
   ||problem (error: undefined
   ||identifier)
   Severity|regression  |normal


--- Comment #2 from Leandro Lucarella leandro.lucare...@sociomantic.com 
2012-01-27 04:00:32 PST ---
(In reply to comment #1)
 This is not a bug.
 
 From the spec: Unlike a template instantiation, a template mixin's body is
 evaluated within the scope where the mixin appears, not where the template
 declaration is defined.
 
 The default for imports is private, so m1.bug is not visible to m.C.

OK, so the case with the alias works because aliases are public by default,
right? Then using private alias m1.bug bug; I get this error:
m2.d(7): Error: module m m2.bug is private

Which describes the problem a little better. I will reopen this (lowering the
importance) to keep in mind the error message should be improved. The current
error gives no NO clue about the real location of the problem, which should be
the instantiation site, I think.

The private alias error is a little better in that regard but could be more
specific too. This is the main reason why this problem was SO hard to reduce to
a small test case. I was extremely hard to find out where the root problem was
because the error is triggered in the template, which in the real code is
instantiated from many places.

Besides that, I think this is a really nasty corner case then. So using a mixin
will require either:

1) Pollute the user's namespace by publicly importing everything the template
use
2) Asking the user to know the details of the mixin implementation and import
things according.

It there any other solution to this problem that doesn't have those 2 problems?
I guess doing the imports INSIDE the template would be an option, thus
polluting only the class name space and not the entire module, but there is
still pollution going on.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 7372] Error provides too little information to diagnose the problem (error: undefined identifier)

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7372


Walter Bright bugzi...@digitalmars.com changed:

   What|Removed |Added

   Severity|normal  |enhancement


--- Comment #3 from Walter Bright bugzi...@digitalmars.com 2012-01-27 
09:28:10 PST ---
It's fundamental to mixing in templates that any scopes it needs to build must
be present in the instantiation context, so yes, the burden is on the designer
of that template to document it.

I'm going to mark this as enhancement because it is working as it was designed
to.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 7372] Error provides too little information to diagnose the problem (error: undefined identifier)

2012-01-27 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=7372



--- Comment #4 from Leandro Lucarella leandro.lucare...@sociomantic.com 
2012-01-27 09:35:15 PST ---
(In reply to comment #3)
 It's fundamental to mixing in templates that any scopes it needs to build must
 be present in the instantiation context, so yes, the burden is on the designer
 of that template to document it.
 
 I'm going to mark this as enhancement because it is working as it was designed
 to.

Fair enough, but I think the error is really bad, I spent at least 2 hours to
figure out what was going on because of what I explain in comment 2. I  I think
it might deserve a little more than enhancement, but this is a grey area. If
a compiler error says can't compile and nothing else, is that an bug or just
an enhancement? The message is not wrong, but is really bad, like in this case
(at a different level, of course).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---