elm-lang / elm-platform

Bundle of all core development tools for Elm
BSD 3-Clause "New" or "Revised" License
762 stars 125 forks source link

record definition recursion in elm #157

Closed neocris closed 8 years ago

neocris commented 8 years ago

look at this perfectly viable elm code:

myobj = {
  some_func = (\str -> str),
  prop_func = (\_ -> myobj.some_func "somestring")
  }

however when compiling this to js it returns an error because on js this kind of object recursivity is not allowed so the reference to myobj in prop_func is undefined, so should the elm compiler produce something that will be rejected at runtime by the target language?

evancz commented 8 years ago

Seems like it works fine to me. Here's the http://sscce.org/

import Html exposing (..)

main =
  text <| toString <| myobj.prop_func 42

myobj = {
  some_func = (\str -> str),
  prop_func = (\_ -> myobj.some_func "somestring")
  }

Prints out "somestring". If you can produce an http://sscce.org that has the problem you describe, and it is not a duplicate of https://github.com/elm-lang/elm-compiler/issues/873 you should open a new issue at https://github.com/elm-lang/elm-compiler/issues