Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong code generation for vars with imported record type. #15

Closed
valexey opened this issue Aug 30, 2013 · 0 comments
Closed

Wrong code generation for vars with imported record type. #15

valexey opened this issue Aug 30, 2013 · 0 comments
Assignees

Comments

@valexey
Copy link
Contributor

valexey commented Aug 30, 2013

MODULE A;
TYPE
 R* = RECORD foo : INTEGER END;
END A.

MODULE B;
IMPORT A;
VAR
 s : A.R;
BEGIN
END B.

Generated code:

var RTL$ = {
    extend: function extend(methods){
        function Type(){
            for(var m in methods)
                this[m] = methods[m];
        }
        Type.prototype = this.prototype;

        var result = methods.init;
        result.prototype = new Type(); // inherit this.prototype
        result.prototype.constructor = result; // to see constructor name in diagnostic

        result.extend = extend;
        return result;
    }
};
var A = function (){
var R = RTL$.extend({
    init: function R(){
        this.foo = 0;
    }
});
return {
    R: R
}
}();
var B = function (A){
var s = new R();
}(A);

So, there is runtime error: ReferenceError: R is not defined

Generated code: var s = new R(); is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants