Skip to content

Enum.map does not work in 0.32 #445

Open

Description

@fazibear

When I'm trying to use Enum.map it throws following error:

Elixir.Inspect.js:78 Uncaught ReferenceError: $Inspect$List$ is not defined
    at Elixir.Inspect.js:78

figured out that Elixir.Inspect.List.js want to import itself

Activity

  1. fazibear commented on Mar 23, 2018

    @fazibear
    ContributorAuthor

    When I try to bundle it with webpack, got ReferenceError: Collectable is not defined

  2. fazibear commented on Mar 29, 2019

    @fazibear
    ContributorAuthor

    I'm tying to fix ReferenceError: Collectable is not defined, but really don't know where I should start.

    This is the source:

    defmodule ElixirGame do
      @moduledoc """
      Documentation for ElixirGame.
      """
    
      def start(_, _) do
        for n <- 1..10 do
          n
        end
        # Enum.map(1..10, fn n ->
        #   ElixirGame.Helpers.log(n)
        # end)
      end
    end
    

    and this is the result:

    'use strict';
    import ElixirScript from './ElixirScript.Core.js';
    import $Range$ from './Elixir.Range.js';
    
    function __info__(kind) {
        const __info__map__ = new Map([[Symbol.for('functions'), [new ElixirScript.Core.Tuple(Symbol.for('start'), 2)]], [Symbol.for('macros'), []], [Symbol.for('attributes'), [new ElixirScript.Core.Tuple(Symbol.for('vsn'), [289843188494319781641132842991731571301])]], [Symbol.for('compile'), [new ElixirScript.Core.Tuple(Symbol.for('version'), [55, 46, 51, 46, 50]), new ElixirScript.Core.Tuple(Symbol.for('options'), [Symbol.for('dialyzer'), Symbol.for('no_spawn_compiler_process'), Symbol.for('from_core'), Symbol.for('no_auto_import')]), new ElixirScript.Core.Tuple(Symbol.for('source'), '/Users/fazibear/dev/elixir_game/lib/elixir_game.ex')]], [Symbol.for('md5'), new ElixirScript.Core.BitString(ElixirScript.Core.BitString.integer(218), ElixirScript.Core.BitString.integer(13), ElixirScript.Core.BitString.integer(196), ElixirScript.Core.BitString.integer(128), ElixirScript.Core.BitString.integer(195), ElixirScript.Core.BitString.integer(174), ElixirScript.Core.BitString.integer(25), ElixirScript.Core.BitString.integer(160), ElixirScript.Core.BitString.integer(239), ElixirScript.Core.BitString.integer(197), ElixirScript.Core.BitString.integer(117), ElixirScript.Core.BitString.integer(37), ElixirScript.Core.BitString.integer(227), ElixirScript.Core.BitString.integer(147), ElixirScript.Core.BitString.integer(122), ElixirScript.Core.BitString.integer(101))], [Symbol.for('module'), Symbol.for('Elixir.ElixirGame')]]);
    
        const value = __info__map__.get(kind);
    
        if (value !== null) {
            return value;
        }
    
        throw new ElixirScript.Core.Patterns.MatchError(kind);
    }
    
    function start(...__function_args__) {
        function recur(...__function_args__) {
            let __arg_matches__ = null;
    
            let __intermediate__ = null;
    
            if ((__arg_matches__ = ElixirScript.Core.Patterns.match_or_default([ElixirScript.Core.Patterns.variable('_'), ElixirScript.Core.Patterns.variable('_')], __function_args__, () => {
                return true;
            })) !== null) {
                let [] = __arg_matches__;
    
                return ElixirScript.Core.SpecialForms._for(ElixirScript.Core.Patterns.clause([ElixirScript.Core.Patterns.variable('n')], (n0) => {
                    return n;
                }, () => {
                    return true;
                }), [ElixirScript.Core.Patterns.list_generator(ElixirScript.Core.Patterns.variable('n'), new Map([[Symbol.for('__struct__'), $Range$], [Symbol.for('first'), 1], [Symbol.for('last'), 10]]))], Collectable, []);
            }
    
            throw new ElixirScript.Core.Patterns.MatchError(__function_args__);
        }
    
        return ElixirScript.Core.Functions.trampoline(new ElixirScript.Core.Functions.Recurse(recur.bind(null, ...__function_args__)));
    }
    
    export default {
        start,
        __MODULE__: Symbol.for('Elixir.ElixirGame'),
        __info__
    };
    

    I'm wondering what's wrong? Why there import for collectable is missing? The problem is with code generation or maybe the problem is where compiler adding imports? Need a little help with that :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions