Giter Site home page Giter Site logo

Comments (4)

dawedawe avatar dawedawe commented on May 29, 2024 2

@dawedawe since you contributed to this feature this might be of interest to you

Thanks for the finding, I'll work on it.

from fsharp.

Larocceau avatar Larocceau commented on May 29, 2024

@dawedawe since you contributed to this feature this might be of interest to you

from fsharp.

vzarytovskii avatar vzarytovskii commented on May 29, 2024

Example project with a case where the bug occurs , and a slightly different version where the bug does not occur

// Nearly identical code that is flagged by the compiler;
// only difference is using List.Append instead of a list comprehension

Difference is that list expression will use list collector, and will result in something like

let tailOrNull = input.TailOrNull
let headOrDefault = input.HeadOrDefault
let listCollector = ListCollector<t>()
listCollector.AddMany(reverse(tailOrNull))
listCollector.Add(headOrDefault)
listCollector.Close()

But when the analysis happens, it probably thinks it's atomic or something.

from fsharp.

vzarytovskii avatar vzarytovskii commented on May 29, 2024

Oh, yeah

[<TailCall>]
let rec recurse (list : list<int>) =
    [ yield! recurse list; () ]

Will result in something like (roughly):

DebugPoint((6,8--6,35), App(toList, [Op(Coerce, App(seq, [App(delay, [Lambda([unitVar], App(append, [.., ..]))])]))]))

Whereas

[<TailCall>]
let rec recurse (list : list<int>) =
    recurse list; ()

into

Sequential(DebugPoint((7,8--7,20), App(.., [..])), DebugPoint((7,22--7,24), ()))

We analyze the latter correctly as sequential expression and produce the warning, and we end up analysing the former as application and decide that it's tail recursive, which we shouldn't.

from fsharp.

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.