www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - name guess by the compiler

Hello,


dmd has a helpful feature, trying to guess which id may have been wrongly t=
yped -- provided the error actually was a typo:
	__trials__.d(20): Error: undefined identifier goo, did you mean variable f=
oo?

But in numerous cases, the source of the error is not a typo, which leads t=
o confusing messages such as:
	__trials__.d(19): Error: undefined identifier i, did you mean alias to?

I have no idea how dmd guesses possible names. But surely there is a kind o=
f probability evaluation used to rank possible guesses. If I'm right, then =
dmd should not output its best guess in every case, but only when its proba=
bility value is higher than a given threshold (to be carefully defines).

Also, the case above probably reveals some kind of bug, since it is hard to=
 imagine how "to" can ever be the best guess for "i" (and there is no alias=
 in the test case). PS: "alias to" is only guessed when the module imports =
std.conv:to. Still, how to guess "to" from "i"? Finally, should the guessin=
g feature exclude (unqualfied) imported symbols?


Denis
-- -- -- -- -- -- --
vit esse estrany =E2=98=A3

spir.wikidot.com
Nov 25 2010