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

Dependencies can become incompatible due to anonymous types #28262

Closed
MaryamZi opened this issue Jan 27, 2021 · 0 comments · Fixed by #29792
Closed

Dependencies can become incompatible due to anonymous types #28262

MaryamZi opened this issue Jan 27, 2021 · 0 comments · Fixed by #29792
Assignees
Labels
Planning/SwanLakeDump All issues planned for Swan Lake GA release Priority/Blocker Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug

Comments

@MaryamZi
Copy link
Member

MaryamZi commented Jan 27, 2021

Description:
Names of anonymous types in a module seem to change across compilations.

Seems like this can cause incompatibilities when using dependencies built on a different lang build

This is probably why we've often been seeing errors like "'lang.array:ArrayIterator' cannot be cast to 'lang.array:$anonType$_1'" and no such field errors for downstream builds.

Assume v1 is the older version which will add the cast from lang.array:ArrayIterator to lang.array:$anonType$_1' which is an object type. Assume the HTTP module is built on this version.

Assume v2 is the newer version where lang.array:$anonType$_1 represents a different anonymous type (may even be a record). Now if we use the HTTP module built on v1 with lang v2, the cast will fail.

Steps to reproduce:
Run the following sample on slp8.1

import ballerina/http;

public function main() {
    http:Cookie c1 = new("foo", "foo");
    http:Cookie c2 = new("bar", "bar");

    http:Request req = new;

    req.addCookies([c1, c2]);
}
ballerina run qwe.bal 

Compiling source
        qwe.bal

Running executable

error: {ballerina}TypeCastError {"message":"incompatible types: 'lang.array:ArrayIterator' cannot be cast to 'lang.array:$anonType$_1'"}
        at ballerina.http.1_0_4.Request:addCookies(http_request.bal:546)
           qwe:main(qwe.bal:8)

Affected Versions:
slalpha1

@MaryamZi MaryamZi added Type/Bug Priority/Blocker Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime labels Jan 27, 2021
@MaryamZi MaryamZi changed the title Dependencies can become incompatible due to anonymous types even without changes to the BIR Dependencies can become incompatible due to anonymous types Jan 27, 2021
@MaryamZi MaryamZi added the Planning/SwanLakeDump All issues planned for Swan Lake GA release label Jan 27, 2021
@manuranga manuranga removed the Team/jBallerina All the issues related to BIR, JVM backend code generation and runtime label Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Planning/SwanLakeDump All issues planned for Swan Lake GA release Priority/Blocker Team/CompilerFE All issues related to Language implementation and Compiler, this exclude run times. Type/Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants