Coder Social home page Coder Social logo

Comments (6)

lochana-chathura avatar lochana-chathura commented on September 25, 2024

The BDD for diff(M1, M2) is as follows.

  • For the failing cases,
Screenshot 2024-05-21 at 07 59 02
(map<any> & map<any> & !map<anydata>) | (!map<any> & map<anydata> & !map<any> & !map<anydata>)
= (map<any> & !map<anydata>) | (map<anydata>  & !map<any>)
= map<any> & !map<anydata> | never
= not empty
  • For the passing cases,
    The tree is same with map<any> and map<anydata> types interchanged.
(map<anydata> & map<anydata> & !map<any>) | (!map<anydata> & map<any> & !map<anydata> & !map<any>)
= (map<anydata> & !map<any>) | (map<any> & !map<any>)
= never | never 
= empty

from ballerina-lang.

lochana-chathura avatar lochana-chathura commented on September 25, 2024

Checked in nBallerina, there the diff(M1,M2) always be never. In our case, BDDs of M1 and M2 are not identical in terms of the indexes. (We have two map<any>/map<anydata> atoms with different indexes) However, in nBallerina we have identical BDDs (Same index for all map<any>/map<anydata>) thus the diff() results in never.

from ballerina-lang.

lochana-chathura avatar lochana-chathura commented on September 25, 2024

Overriding MappingAtomicType and ComplexSemTypes' equals() and hashCode() solved the issue for the original sample. However the following still fails as deep equality is not considered in subtypeDataList.

type M map<(1|2|3)>;
type N map<(1|2|3)>;

// @type M1 = M2
type M1 M|map<(1|2)>;

type M2 N|map<(1|2)>;

from ballerina-lang.

lochana-chathura avatar lochana-chathura commented on September 25, 2024

I was able to reproduce the same scenario(for the original sample) in nBallerina by modifying mappingAtom() as follows.

   isolated function mappingAtom(MappingAtomicType atomicType) returns TypeAtom {
       lock {
           TypeAtom? ta = self.atomTable[atomicType];
           if ta != () {
               TypeAtom result = { index: self.atomTable.length(), atomicType };
               return result;
           }
           else {
               TypeAtom result = { index: self.atomTable.length(), atomicType };
               self.atomTable.add(result);
               return result;
           }
       }
   }

The BDD for diff(M1,M2) I get there is different and it resulted in the correct emptiness. So there is a bug in diff() in jBallerina.

from ballerina-lang.

lochana-chathura avatar lochana-chathura commented on September 25, 2024

The root cause was found to be a bug in mappingInhabited() when porting. Both nBallerina and jBallerina produce the same BDDs. The previous BDD explained here turned out to be a mistake.

from ballerina-lang.

lochana-chathura avatar lochana-chathura commented on September 25, 2024

Fixed in PR #42791

from ballerina-lang.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.