Time derivative of user defined class makes compiler crash

Bug #396095 reported by Eike on 2009-07-06
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Freeode
High
Eike

Bug Description

Here is a little program that makes the compiler crash with an internal error. It involves assigning to the time derivative of a user defined class. The error happens in the code generator.

I can't spontaneously understand the error to fix it, so I file a bug.

This is the program that crashes the compiler. When the alternative, commented out, code is used, the program compiles.
-------------------------------------------------------------------
 -------------------------------------------------------------------
class Vec2:
 class Vec2:
    data x: Float role_unknown
     data x: Float role_unknown
    data y: Float role_unknown
     data y: Float role_unknown

    func __assign__(this, other):
        x = other.x
         x = other.x
        y = other.y
         y = other.y

    func __diff__(this):
        data res: Vec2
         data res: Vec2
        replace_attr(res.x, $x)
         replace_attr(res.x, $x)
        replace_attr(res.y, $y)
         replace_attr(res.y, $y)
        return res
         return res

data vg: Vec2
vg.x = 0
 vg.x = 0
vg.y = -9.81
 vg.y = -9.81

class Throw:
    data v: Vec2
     data v: Vec2

    func dynamic(this):
        #$v.x = 0 #This code
         #$v.x = 0 #This code
        #$v.y = -9.81 #works
         #$v.y = -9.81 #works
        $v = vg #This code crashes the compiler
         $v = vg #This code crashes the compiler

compile Throw
-----------------------------------------------------
 -----------------------------------------------------

Eike (eike-welk) wrote :
Changed in freeode:
importance: Undecided → High
status: New → Confirmed
Eike (eike-welk) on 2009-09-03
summary: - Time terivative of user defined class makes compiler crash
+ Time derivative of user defined class makes compiler crash
Eike (eike-welk) wrote :

Possible algorithm for derived variables of user defined class:

Instance must have an attribute:

data _dt: Pointer

Function to return/create differential:

func __diff__(self):
    if self._dt.is_set():
        return self._dt.get()
    else:
        data m: MyClass
        associate_state_diff(self.x, m.x)
        self._dt = m
        return m

Eike (eike-welk) on 2010-07-10
tags: added: interpreter
Eike (eike-welk) on 2010-07-11
Changed in freeode:
milestone: none → 0.4.2
Eike (eike-welk) on 2012-02-29
Changed in freeode:
assignee: nobody → Eike (eike-welk)
status: Confirmed → In Progress
description: updated
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers