Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

PJass updates

Discussion in 'Warcraft Editing Tools' started by LeP, Oct 25, 2014.

  1. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    479
    Resources:
    0
    Resources:
    0
    Having a script to reproduce it myself would help. Minimal example or whole mapscript is fine.
    PM is also fine, if you dont want it to be public.
     
  2. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    479
    Resources:
    0
    Resources:
    0
    Thanks to @Prometheus3375 i have fixed an off-by-one error in the error message construction.
     

    Attached Files:

  3. DracoL1ch

    DracoL1ch

    Joined:
    Dec 12, 2010
    Messages:
    2,038
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    Code (vJASS):

    globals
    trigger TriggerGoldPerSecond
    endglobals

    //somewhere else
    call DisableTrigger(TriggerGoldPerSecond)

     

    Would be great if Pjass could analyze that variable never being used withing "set" statement therefore using it will crash. Currently it only does it for local scopes
     
  4. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    479
    Resources:
    0
    Resources:
    0
    Sure that would be nice but it's also far from trivial. Even when you don't consider pjass' way of operation.
    Also at one point one would be better served with a standalone jass linter or the like instead of stuffing everything into pjass.
     
  5. DracoL1ch

    DracoL1ch

    Joined:
    Dec 12, 2010
    Messages:
    2,038
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    hm, I thought it's the same as finding non-init'd locals, just bigger scope. W/e, just saying
     
  6. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    479
    Resources:
    0
    Resources:
    0
    Thing with locals is that you can see the whole control flow. I would assume with globals it would give false positives due to interprocedural nature of globals. I think the local check never gives false positives.
    I could use the same code for globals and see what happens.
     
  7. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    479
    Resources:
    0
    Resources:
    0
    The uninitialized var check has been expanded. Now it also checks for uninitialized globals in the globals block by default.
    Example:
    Code (vJASS):

    globals
        integer a
        integer b = a + 3
    endglobals
     

    Code (Text):

    $ ./pjass tests/should-fail/uninit-globals-in-globals.j
    tests/should-fail/uninit-globals-in-globals.j:3: Variable a is uninitalized
    tests/should-fail/uninit-globals-in-globals.j failed with 1 error
    Parse failed: 1 error total
     
    You can also now use the same check there already is for locals on globals with the flag +checkglobalsinit
    It is not default since it might be reporting false positives such as this
    Code (Text):

    $ ./pjass +checkglobalsinit tests/common.j tests/Blizzard.j
    Parse successful:     2418 lines: tests/common.j
    tests/Blizzard.j:19891: Variable bj_stockPickedItemType might be uninitalized
    tests/Blizzard.j failed with 1 error
    Parse failed: 1 error total
     
     

    Attached Files:

  8. DracoL1ch

    DracoL1ch

    Joined:
    Dec 12, 2010
    Messages:
    2,038
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    thank you!
     
  9. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    479
    Resources:
    0
    Resources:
    0
    Just to bring this in sync with git.
    • Various performance improvments
    • Better error message for non-integer array indices
      Code (vJASS):
      globals
              integer array foo
              integer bla = foo[3.1]
      endglobals
      function xx takes nothing returns integer
              local integer array asdf
              return asdf["foo"]
      endfunction
       

      Code (Text):

      $ pjass test.j
      test.j:3: Cannot convert real to integer as index for array foo
      test.j:7: Cannot convert string to integer as index for array asdf
      test.j failed with 2 errors
      Parse failed: 2 errors total

       
     

    Attached Files:

  10. Prometheus3375

    Prometheus3375

    Joined:
    Jul 20, 2018
    Messages:
    100
    Resources:
    0
    Resources:
    0
    Is this report okay? I'm using windows-1251 encoding and latest pjass.exe.
    [​IMG]
     

    Attached Files:

  11. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    479
    Resources:
    0
    Resources:
    0
    Nope that's a jasshelper error message. Pjass would simply report "Syntax Error".
     
  12. Prometheus3375

    Prometheus3375

    Joined:
    Jul 20, 2018
    Messages:
    100
    Resources:
    0
    Resources:
    0
    Why
    _SomeCharSequence
    is invalid identifier? Used for name of globals.
    In other words, must not names in JASS2 start with _ or is it pjass mistake?
     
  13. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    479
    Resources:
    0
    Resources:
    0
    Indeed, names in jass have to start with a letter and have to end in either a letter or a number. inbetween numbers, letters and underscores are allowed.
     
  14. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    479
    Resources:
    0
    Resources:
    0
    Small update triggered by this. But some other stuff added aswell.
    Here's the shortlog from the last version released here.
    Code (Text):

    Jesse Rogers (1):
        Support Apple by defining _aligned_malloc
    lep (8):
        Merge pull request #1 from theQuazz/feature/support-apple
        Specify minimum bison version in readme
        Report natives after function defintions
        Merge branch 'master' of ssh://192.168.1.5:52/home/git/pjass
        More newline stuff
        Added reserved keyword 'alias'
        Better error message for `type` as a name
        Fix release target
     
     

    Attached Files:

  15. Ralle

    Ralle

    Owner

    Joined:
    Oct 6, 2004
    Messages:
    11,464
    Resources:
    21
    Tools:
    2
    Maps:
    5
    Tutorials:
    14
    Resources:
    21
    Open!
     
  16. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    479
    Resources:
    0
    Resources:
    0
    Added a new option
    +checkstringhash
    which looks for calls to
    StringHash
    with a literal string as its argument. If pjass finds two calls with different strings which would hash to the same integer pjass will report an error. Do note though that you have to enable that option yourself; it's not on by default.
    To do this i use the code i have reversed years ago. But afaik there have been changes to the
    StringHash
    native; it should still work for plain old ASCII strings but for multibyte characters my reversed code produces different hashes. If anyone wants to dump the new asm i will happily reverse engineer it (or maybe Blizzard sees their mistake and reverses the change).
    While we're at it: some patches ago Blizzard made the backward incompatible change of giving
    alias
    a keyword. From what i know it never did anything so maybe remove it again? Or atleast document such things.

    I've also taken this opportunity to bring the Github page up-to date.
     

    Attached Files:

  17. Aniki

    Aniki

    Joined:
    Nov 7, 2014
    Messages:
    564
    Resources:
    6
    Tools:
    1
    Maps:
    1
    Spells:
    1
    JASS:
    3
    Resources:
    6
    pjass does not report an error when the operand of 'function' is a native:

    Code (vJASS):

    native foo takes nothing returns nothing
    globals
        code c = function foo // no error
    endglobals
     


    Tested with "pjass version git-814075e".
    I think this crashes the game at runtime.
     
  18. DracoL1ch

    DracoL1ch

    Joined:
    Dec 12, 2010
    Messages:
    2,038
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    well, as long as you can launch the map with that code, it's not really an issue :D
     
  19. LeP

    LeP

    Joined:
    Feb 13, 2008
    Messages:
    479
    Resources:
    0
    Resources:
    0
    Checking that is easy. If you make sure that this actually crashes ingame i will gladly add this as a check. For testing purpose you can use
    native TriggerSyncStart takes nothing returns nothing
    .
     
  20. Aniki

    Aniki

    Joined:
    Nov 7, 2014
    Messages:
    564
    Resources:
    6
    Tools:
    1
    Maps:
    1
    Spells:
    1
    JASS:
    3
    Resources:
    6
    Tested on 1.31 and it crashes when trying to execute the instruction that implements the 'function' operation:
    Code (vJASS):

        local code c = function ClearSelection
     


    I suppose instead of giving an error (which it doesn't) the compiler could've generated an anonymous stub like:
    Code (vJASS):

    function ClearSelection* takes nothing retuns nothing
        call ClearSelection()
    endfunction
     

    or something, but that would've been too clever for very little gain.