Internal error on compile

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
victorf
Posts: 342
Joined: 01 January 2006, 4:08 AM
Location: Schenectady, New York

Internal error on compile

Post by victorf »

While compiling the program WindReader.bas, I received the following error message:

Internal error: expression.cpp(3207), Rev 881: unexpected binary operator, "WindReader.bas" line 358

These are lines 357 and 358:

Code: Select all

  xproj = cos(DegToRad(90.0 - sensordata.azimuth)) _
                     *  (height / tan(DegToRad(sensordata.elevation)))  'meters
Where the local variable xproj is defined:

Code: Select all

  Dim xproj as Single
  Dim height as Single 

And global variable sensordata is of this type:

Code: Select all

Structure SensorDataType
  Public azimuth as Single
  Public elevation as Single
  Public roll as Single
End Structure
What does the message mean? Are errors of this kind documented somewhere?

Any enlightenment will be appreciated.

Vic
Vic Fraenckel
KC2GUI
windswaytoo ATSIGN gmail DOT com
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Internal error on compile

Post by dkinzer »

victorf wrote:What does the message mean?
An Internal Error is generated when the ZBasic compiler encounters a situation that it cannot handle. This is different from a syntax error or a semantic error which arises because an error in your code. Usually, it arises because some data element in an internal datastructure is missing or inconsistent with other data elements. In such cases, we chose to emit the Internal Error rather than to continue using bad data.

Normally, such errors should not arise. When they do, it means that either there is a coding error in the compiler or we neglected to handle a certain set of circumstances. The challenge is to locate the source of the error - often the ultimate source of the error is far removed from the point at which the problem is detected. We will attempt to reproduce the problem here using a simplified test case although this is often unsuccessful. If you can send us source code that exhibits the problem (either your full source code or a simplified test case) that will expedite locating and resolving the problem.
- Don Kinzer
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Internal error on compile

Post by dkinzer »

victorf wrote:While compiling the program WindReader.bas, I received the following error message:
I don't know yet why the problem is occurring but it appears that you can work around it by temporarily replacing the code on lines 357 through 361 of WindReader.bas with the following:

Code: Select all

  Dim azimuth as Single
  azimuth = sensordata.azimuth
  xproj = cos(DegToRad(90.0 - azimuth)) _
    * (height / tan(DegToRad(sensordata.elevation)))	'meters

  yproj = sin(DegToRad(90.0 - azimuth)) _
    * (height / tan(DegToRad(sensordata.elevation)))	'meters
The change simply introduces a temporary variable to hold the azimuth value.
- Don Kinzer
victorf
Posts: 342
Joined: 01 January 2006, 4:08 AM
Location: Schenectady, New York

Post by victorf »

Don,

Thanks for the work-around! I'll be interested in hearing what you find after the investigation.

Vic
Vic Fraenckel
KC2GUI
windswaytoo ATSIGN gmail DOT com
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

victorf wrote:I'll be interested in hearing what you find after the investigation.
The short answer is that the problem was caused by a coding error in one of the methods of a C++ class that represents a structure member reference.

The longer answer is that code is generated for the DegToRad() function (and a few similar functions) in a special way where a new expression is constructed using a conversion factor together with the parameter provided. The C++ method for duplicating an expression element for the class that represents the structure member reference wasn't implemented correctly. This led to an inconsistency in the expression which was discovered later in the code generating process resulting in the Internal Error that you saw.

We've resolved the error and augmented the test suite to cover this and related situations.
- Don Kinzer
victorf
Posts: 342
Joined: 01 January 2006, 4:08 AM
Location: Schenectady, New York

Post by victorf »

Don,

Code: Select all

sensordata.elevation
I replaced this in both expressions as well using the same method as you suggested for sensordata.azimuth for the sake of symmetry. Everything works fine now.

Thanks again

Vic
Vic Fraenckel
KC2GUI
windswaytoo ATSIGN gmail DOT com
Post Reply