When did JassHelper get this messed up?

Jesus4Lyf

Good Idea™
Reaction score
397
JASS:
library MyDog initializer OnInit
    globals
        private integer 5=2
    endglobals
    private function OnInit takes nothing returns nothing
        call BJDebugMsg(I2S(5)) // prints 2
        set 5=7
        call BJDebugMsg(I2S(5)) // prints 7
    endfunction
endlibrary

Mmm... defines! <_<

... Err... Could we always do that?
And I wonder when he'll fix that.
 

Azlier

Old World Ghost
Reaction score
461
I don't expect it to work with scopeless globals, however. I think the only reason that works is because it compiles into MyDog__5.
 

Anachron

New Member
Reaction score
53
It's not a bug. It's most likely what Azlier already said. Its because scopes / librarys will overwrite the variable name, so making it valid.

"It's not a bug, it's a feature!"
 

Jesus4Lyf

Good Idea™
Reaction score
397
It's not a bug. It's most likely what Azlier already said. Its because scopes / librarys will overwrite the variable name, so making it valid.

"It's not a bug, it's a feature!"
Did you just tell me that
JASS:
library MyDog initializer OnInit
    function interface 4 takes integer 6 returns nothing
    function interface 7 takes nothing returns nothing
    globals
        private 4 8
        private 7 3=9
        private string 2
    endglobals
    function kk takes integer I returns nothing
        set 2=I2S(I)
    endfunction
    private function OnInit takes nothing returns nothing
        set 8=kk
        call 8.evaluate(3)
        call BJDebugMsg(2)
    endfunction
endlibrary

is working as intended? Even Blizzard doesn't do that.
 

Anachron

New Member
Reaction score
53
MyDog__4 is a valid name for a variable.

It's ugly to use, but there could be situations in which this is useful.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Lol dude...
JASS:
library MyDog
    private keyword 3
    struct four
        four 3=2
        private static method onInit takes nothing returns nothing
            local integer this=1
            call thistype.create()
            call BJDebugMsg(&quot;For three to be &quot;+I2S(3)+&quot;, just follow my clue...&quot;)
        endmethod
    endstruct
endlibrary

:nuts:
JASS:
library MyDog initializer OnInit
    private keyword 4
    private function 4 takes nothing returns integer
        return 4+4
    endfunction
    private function OnInit takes nothing returns nothing
        call BJDebugMsg(I2S(4()))
    endfunction
endlibrary

In case you didn't realise 4+4=2, or some other value depending on how much vJass you use...
 

Jesus4Lyf

Good Idea™
Reaction score
397
Why would you name a variable like a number? It's stupid.
Because I like to hard code the number of players in my map like a magic number, and then change it later without changing my code?
JASS:
library MyDog initializer OnInit
    globals
        private integer 8=12
    endglobals
    private function OnInit takes nothing returns nothing
        local integer i=8
        loop
            set i=i-1
            call BJDebugMsg(GetPlayerName(Player(i)))
            exitwhen i==0
        endloop
    endfunction
endlibrary

That's the kind of reason it's a bug.

Edit:
Or maybe we like to divide by 0, but decide that maybe that's not so bright after all...
JASS:
library MyDog initializer OnInit
    globals
        private integer 0=1
    endglobals
    private function OnInit takes nothing returns nothing
        call BJDebugMsg(I2S(3/0))
    endfunction
endlibrary
 

Jesus4Lyf

Good Idea™
Reaction score
397
Moar syntax!
JASS:
library NoMoreVariableNames
    private keyword 1=7
    private keyword 2=5
    private keyword 3=2
    private keyword 4=3
    private keyword 5=4
    private keyword 6=1
    private keyword 7=5
    private keyword 8=7
    private keyword 9=2
    private keyword 0=50
    
    struct NoMoreVarNames
        integer 2=97
        string 9=&quot;king&quot;
        string 6=9
        integer 0=2
        method operator 7 takes nothing returns string
            call this.destroy() // lol??
            return R2S(SquareRoot(this))
        endmethod
        private static method onInit takes nothing returns nothing
            local thistype this=thistype.create()
            call BJDebugMsg(I2S(0))
            call BJDebugMsg(6)
            call BJDebugMsg(7)
            set this=thistype.create()
            set this=thistype.create()
            call BJDebugMsg(7) // 7 is changin..
            set this=thistype.create()
            set this=thistype.create()
            set this=thistype.create()
            call BJDebugMsg(7)
        endmethod
    endstruct
endlibrary
 

chobibo

Level 1 Crypt Lord
Reaction score
48
Anyone tried reporting the bug? I think it's minor since it's unconventional to use numbers as variable names, I know I won't.
 

codemonkey

Code monkey not crazy, just proud.
Reaction score
66
JASS:
globals
    string 42 = &quot;The meaning of life&quot;
endglobals


I recommend applying this patch to all of your maps.
 

Sickle

New Member
Reaction score
13
That does not compile, codemonkey. A variable name cannot be an integer. The reason it works with private variables is because they are named ScopeName__Variable within the map script.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
I guess your library can't share the secret of life then.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top