Coder Social home page Coder Social logo

Comments (6)

kg avatar kg commented on August 10, 2024

Can you provide a simple test case?

from jsil.

matra774 avatar matra774 commented on August 10, 2024

Here is a sammpe.

static void TestNestedLambda()
{
  var set1 = new int[] { 1, 2, 3 };
  var set2 = new int[] { 2, 3, 5 };

  var intersection = set1.Where(x => set2.Any(y => y == x)); 

}

The problem occurrs if you have nested lambda expressions (i.e. the innse lambda expresion references the variable from the outer one).

If you add the folowing block after the assigment to emitInLine:

if (methodMember.Method.IsIgnored && !emitInline) // matra774 https://github.com/kevingadd/JSIL/issues/37
{
  Console.WriteLine("WARNING: {0} is ignored, but is not considered to be emmited inline. ", methodDot);
}

You will get the following warning when runing JSILC:

WARNING: <JSType 'TestHelloWorld.Program/<>c__DisplayClass2/<>c__DisplayClass4'>.<JSStringIdentifier 'prototype'>.<JSMethod '<TestNestedLambda>b__1'> is ignored, but is not considered to be emmited inline. 

Here are some other sasamples from Mono's implementation of LINQ:

WARNING: <JSType 'System.Linq.Enumerable'>.<JSMethod '<ToLookup>b__bb`2'> is ignored, but is not considered to be emmited inline. 

WARNING: <JSType 'System.Linq.Enumerable/PredicateOf`1<T>'>.<JSMethod 'cctor>b__c9'> is ignored, but is not considered to be emmited inline. 

WARNING: <JSType 'System.Linq.Enumerable/Function`1<T>'>.<JSMethod 'cctor>b__cb'> is ignored, but is not considered to be emmitd inline. 

from jsil.

kg avatar kg commented on August 10, 2024

All the issues demonstrated by your test case should be fixed in bf107bc.

from jsil.

markusjohnsson avatar markusjohnsson commented on August 10, 2024

I'm not positive it is fixed though as I'm seeing a related error.

Will continue to debug and hopefully provide another test case (oh, and a fix if I can figure it out)

from jsil.

markusjohnsson avatar markusjohnsson commented on August 10, 2024

Didn't come up with a test for this.. but what happened for me was that I had a method with identifier "<System.Collections.ICollection.CopyTo>b__0" (from mono's Dictionary) which was ignored (it is a delegate), but "compilerGenerated" became false so it went straight to the exception.

I've tested to always emit inline if method is ignored and it works so far. I haven't ran the unit tests using this though because I'm in my corlib setup and the unit tests doesn't compile.. Might continue on sunday.

from jsil.

kg avatar kg commented on August 10, 2024

Emitting if ignored sounds like a reasonable heuristic. I'll see if that breaks any tests.

from jsil.

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.