Time derivative of user defined class makes compiler crash

Bug #396095 reported by Eike
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Freeode
In Progress
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
-----------------------------------------------------
 -----------------------------------------------------

Tags: interpreter
Revision history for this message
Eike (eike-welk) wrote :
Changed in freeode:
importance: Undecided → High
status: New → Confirmed
Eike (eike-welk)
summary: - Time terivative of user defined class makes compiler crash
+ Time derivative of user defined class makes compiler crash
Revision history for this message
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)
tags: added: interpreter
Eike (eike-welk)
Changed in freeode:
milestone: none → 0.4.2
Eike (eike-welk)
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.