Bug 276100 - Problems when reassigning a built-in name
Summary: Problems when reassigning a built-in name
Alias: None
Product: kdev-python
Classification: Developer tools
Component: general (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: 1.2.0
Assignee: Sven Brauch
Depends on:
Reported: 2011-06-20 03:01 UTC by Eike Hein
Modified: 2011-06-25 11:04 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Note You need to log in before you can comment on or make changes to this bug.
Description Eike Hein 2011-06-20 03:01:20 UTC
Given a file:

all = 1
all = 2
all = 3

a) "all" in the first line won't highlight on mouseover nor show a tooltip.
b) "all" in lines 2 and 3 will both highlight when hovering either of them, but show a tooltip "Invalid type" and point to a declaration in builtindocumentation.py.

kdev-python should detect (but quite possibly warn in the Problems docker) that I'm reassigning the builtin name and treat it like any other variable.
Comment 1 Sven Brauch 2011-06-20 16:38:55 UTC
Hmm, the problem is that a Declaration apparently cannot have a type like unsure (some_function, int), which would mix function and integral types in a single unsure type. I'll look into it.
Comment 2 Sven Brauch 2011-06-21 10:47:27 UTC
If you first define a function, the re-assign it with another value (like, 3) then an error should be reported now (this is due to technical reasons, and also because you usually don't want to do it). Do you think that's okay?
Also I'm not quite sure it works correctly, it seems to be doing strange things sometimes.

Comment 3 Eike Hein 2011-06-21 18:45:58 UTC
Hm to be honest, no, I don't, although I recognize there will be different opinions about this, so there's no real "right" :).

IMHO Python's builtins namespace is pretty large and contains a fair amount of names that are simply too useful in general code to fully avoid - like "all", for example. I think there's real value to an IDE *warning* me about overriding a builtin in case I do it accidentally, but reporting it as an error by default feels a bit too harsh to me personally. The real code I noticed the issue in deliberately used "all" for example.

By the way, even with the latest changes the behavior is a bit weird ... all three lines now get the "Problem in Semantic Analysis" tooltip, but the last two "all"s are still highlighted together when any of the two is hovered, while the first stands alone.
Comment 4 Sven Brauch 2011-06-21 19:13:40 UTC
Yeah, I noticed it still doesn't work. I also agree, after thinking about it, that this solution is not really acceptable. I'll try to find something better.
Comment 5 Sven Brauch 2011-06-24 23:42:42 UTC
Okay, maybe it works like this now? :)
Comment 6 Eike Hein 2011-06-25 04:27:40 UTC
Getting closer :-).

This works fine now:

all = 1
all = 2
all = 3

All of those now get highlighted together when any of them is hovered and the same tooltip is shown for all of them. It's saying the var is float, which is a bit odd, since really the name is being assigned to an integer literal, but I've seen that before, so it's an unrelated bug I guess (is it a bug or intentional, actually?).

However ... when I just have this in the file:


... and hover it, the tooltip says "Invalid type" and "Kind: Function". Why "Invalid type"? :)
Comment 7 Eike Hein 2011-06-25 10:21:11 UTC
As you suggested on IRC, wiping ~/.kdevduchain fixed the "Invalid type" thing :-).

Aside from integer literals being taken for floats, which is a separate issue anyway, looks like this is fixed now. Thanks!
Comment 8 Sven Brauch 2011-06-25 11:04:26 UTC
Okay, fine.
Integers <> Floats just isn't implemented yet, as I'll have to do this manually (i.e. python just tells you "number"). It's on my to-do-list. :)