elm / compiler

Compiler for Elm, a functional language for reliable webapps.
https://elm-lang.org/
BSD 3-Clause "New" or "Revised" License
7.55k stars 662 forks source link

Code generator outputing functions in wrong order. #1575

Closed juanibiapina closed 7 years ago

juanibiapina commented 7 years ago

Minimal (er, kinda) reproducing it: https://github.com/juanibiapina/elm-typeerror

I've tried reproducing it with a minimal set of simple functions but was not able. There must be something related to one of the functions that I'm using that I'm missing.

Mac OSX Yosemite. Chrome. Elm 0.18.

The error is:

Uncaught TypeError: _user$project$Main$urlParam is not a function
    at Object.eval (Main.elm:13428)
    at eval (Main.elm:13854)
    at Object.<anonymous> (bundle.js:1381)
    at __webpack_require__ (bundle.js:556)
    at fn (bundle.js:87)
    at eval (index.js:2)
    at Object.<anonymous> (bundle.js:1336)
    at __webpack_require__ (bundle.js:556)
    at fn (bundle.js:87)
    at eval (multi_main:3)1

And here's a snippet of the generated JS:

var _user$project$Main$matchers = _ktonon$url_parser$UrlParser$oneOf(
    {
        ctor: '::',
        _0: A2(_ktonon$url_parser$UrlParser$map, _user$project$Main$TopRoute, _ktonon$url_parser$UrlParser$top),
        _1: {
            ctor: '::',
            _0: A2(
                _ktonon$url_parser$UrlParser$map,
                _user$project$Main$LoginRoute,
                A2(
                    _ktonon$url_parser$UrlParser_ops['<?>'],
                    _ktonon$url_parser$UrlParser$s('login'),
                    _user$project$Main$urlParam('redirect'))), <------------------ ERROR
            _1: {ctor: '[]'}
        }
    });
var _user$project$Main$urlParam = function (name) {
    return A2(_ktonon$url_parser$UrlParser$customParam, name, _user$project$Main$parsePath);
};
process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

jvoigtlaender commented 7 years ago

Duplicate of any (or several) of #1516, #1527, #1529, https://github.com/elm-lang/elm-compiler/issues/1560?

evancz commented 7 years ago

Thanks for making that list @jvoigtlaender!

Added all of these to https://github.com/elm-lang/elm-compiler/issues/1377 so they can be addressed together in one pass.