name guess by the compiler

spir denis.spir at gmail.com
Thu Nov 25 01:45:22 PST 2010


Hello,


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

But in numerous cases, the source of the error is not a typo, which leads to 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 of 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 probability 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 guessing feature exclude (unqualfied) imported symbols?


Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d mailing list