gama-platform / gama.old

Main repository for developing the 1.x versions of GAMA
GNU General Public License v3.0
304 stars 99 forks source link

Problem with variable/function identification #3632

Closed curiosity29 closed 1 year ago

curiosity29 commented 1 year ago

Describe the bug Using 2 variables or 2 actions with the same name in the global and in a species result in unexpected behaviors. With action act, the editor recognize does not highlight the correct action but still runs with the correct action in the species and produces an error warning if the action is missing like normal. With variable x, the editor highlights the correct variable in the global but still runs with the wrong variable in the species.

To Reproduce model Rename

global
{
    int x <- 3;
    action act
    {
        ask sp {do act;}
    }
    init
    {
        create sp;
        do act;
    }
}

species sp {
    int x;
    init{self.x <- x;}
    action act{write self.x;}
}

experiment ex {}

Output 0

Screenshots action act 3 variable x: x

Additional context Same identification and output even with more specification: 4

AlexisDrogoul commented 1 year ago

The problem of highlight / documentation of vars/actions with the same name in different scopes is already documented in gama-platform/gama2#46 and it will not be addressed anytime soon (at least in this branch of GAMA).

For the rest, the behaviour is completely normal. x in sp is treated as a local attribute (although the highlight is again false as it points towards the global attribute) so when you write self.x <- x or int x <- x; you just do not change its value (which remains at 0). If you wanted to change its value with the global x, you'd have to write something like self.x <- host.x or int x <- host.x;

AlexisDrogoul commented 1 year ago

Closing as it is (at least internally) a direct consequence / dependency of gama-platform/gama2#46