Should compile?

Found a bug? Post information about it here so we can fix it!

Moderator: Moderators

Post Reply
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Should compile?

Post by rrTea »

It seems strange that Variable1.T compiles, I'd expect only R/G/B/A and X/Y/Z are allowed.

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" FileVersion="2">
  <OnLoaded>
    <ZExpression>
      <Expression>
<![CDATA[Variable1.X = 1;

trace ("It doesn't exist but " + intToStr(Variable1.T) );]]>
      </Expression>
    </ZExpression>
  </OnLoaded>
  <Content>
    <Variable Name="Variable1" Type="6"/>
  </Content>
</ZApplication>
User avatar
Ats
Posts: 706
Joined: Fri Sep 28, 2012 10:05 am
Contact:

Re: Should compile?

Post by Ats »

That's interesting. I would expect only X and Y in your example since it's a vec2...
But almost all the letters are working, the commented ones are not:

Code: Select all

//trace ("A " + intToStr(Variable1.A) );
//trace ("B " + intToStr(Variable1.B) );
trace ("C " + intToStr(Variable1.C) );
trace ("D " + intToStr(Variable1.D) );
trace ("E " + intToStr(Variable1.E) );
trace ("F " + intToStr(Variable1.F) );
trace ("G " + intToStr(Variable1.G) );
trace ("H " + intToStr(Variable1.H) );
trace ("I " + intToStr(Variable1.I) );
trace ("J " + intToStr(Variable1.J) );
trace ("K " + intToStr(Variable1.K) );
trace ("L " + intToStr(Variable1.L) );
trace ("M " + intToStr(Variable1.M) );
trace ("N " + intToStr(Variable1.N) );
trace ("O " + intToStr(Variable1.O) );
trace ("P " + intToStr(Variable1.P) );
trace ("Q " + intToStr(Variable1.Q) );
trace ("R " + intToStr(Variable1.R) );
trace ("S " + intToStr(Variable1.S) );
trace ("T " + intToStr(Variable1.T) );
trace ("U " + intToStr(Variable1.U) );
trace ("V " + intToStr(Variable1.V) );
//trace ("W " + intToStr(Variable1.W) );
trace ("X " + intToStr(Variable1.X) );
trace ("Y " + intToStr(Variable1.Y) );
//trace ("Z " + intToStr(Variable1.Z) );
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Should compile?

Post by VilleK »

Indeed this should not compile :). I will stop it from working so please don't write code that relies on it working.
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Re: Should compile?

Post by rrTea »

Ville: Of course I wasn't really relying on such code :D, I just discovered it by mistake during editing.

And as for the next one, I already posted about this elsewhere, but was never able to isolate what exactly is breaking it. Well I finally managed to boil it down to the simplest possible test case! I present you… The ultimate "Shouldn't compile" example!

Paste this into an empty ZExpression and hit Alt+Enter:

Code: Select all

}
User avatar
VilleK
Site Admin
Posts: 2318
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Re: Should compile?

Post by VilleK »

:).

Yep, another problem.

It is the old bug that extra "}" at the end is not parsed as an error. You can have too many of them in a ZLibrary too and the compiler does not protest.

Code: Select all

void f() {
}

}
}
I haven't found a fix for this that seems worth the trade-off "how likely is this change to possibly break some code by introducing some unforeseen edge-case, compared to how serious is this bug". So it will still be here for now.
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Re: Should compile?

Post by rrTea »

No worries – it can get confusing but at least it's not breaking anything.
Post Reply