Getting CIL generation Stack empty message

Alright, doing a CIL generation few days ago and got again the "CIL generation: Stack empty", so decided to try and understand (again) why this is happening. Found one more reason what would cause this and how to solve it.

Basically the issue appeared on a

    update_recordSet tmpTable
        setting aName = dirPerson.Name
        join .....

        join hcmWorker
            where hcmWorker.RecId == value
        join dirPerson
            where dirPerson.RecId == hcmWorker.Person;


As you know this compiles just fine, but the CIL fails. The cause looks very simple once you start to think what the compiler would do.

The DirPerson table is extended (extending DirPartyTable), and you are using a field (Name) from the parent table in the sql statement. The X++ compiler knows very well how to handle this, but that's not the case when generating the IL.

So, the fix: just replaced DirPerson with DirPartyTable in the sql statement.

No comments:

Post a Comment