Commit Graph
54 Commits
Author SHA1 Message Date
José Valim 79faa1f706 Do not export case and receive vars 2014-01-04 10:45:13 +01:00
José Valim 9b22b6d883 Ensure local is disabled on module definitions 2014-01-03 17:57:24 +01:00
José Valim 1c4b759c4e Bring back no name and simplify var merging 2014-01-01 12:22:49 +01:00
José Valim 9cd56804ea Use a main counter for hygienic variables 2013-12-31 14:20:24 +01:00
José Valim 7836493d23 Do not leak clause heads, closes #1948 2013-12-30 23:12:44 +01:00
José Valim 83c93beaa6 Get rid of environment macro counter in favor of a global one 2013-12-30 11:45:23 +01:00
José Valim b03e2173a5 Rename translate_each to translate and temp_vars to match_vars 2013-12-29 16:08:58 +01:00
José Valim 254065d3c4 Clean up synax_error, asstions and merge mechanisms 2013-12-29 14:22:45 +01:00
José Valim f8b019c7c8 Move to the new expansion on the front-end 2013-12-28 23:14:55 +01:00
José Valim c4419268b8 Move module compilation to rely on elixir_exp 2013-12-28 15:01:31 +01:00
José Valim 8847f8ed68 Start locals expansion 2013-12-19 15:33:13 +01:00
José Valim f62c26b9b6 Ensure record aliases in the same quote can be accessed, closes #1915
This commit also simplifies macro expansion for both imports and aliases
to always give higher preference to the macro environment rather than
the caller one, if such is available. The deal is to simplify both the
code and understanding of how macros work.
2013-12-07 20:01:11 +01:00
José Valim 043edd4990 location: :keep only affect function definitions
This commit changes how metadata is stored once location: :keep
is used and also removes the __scope__ special form.

Closes #1877
2013-11-25 11:35:00 +01:00
José Valim d7179b404b Port module_nesting handler to Elixir 2013-11-24 13:42:01 +01:00
José Valim c2243e2c28 Make module compilation work with elixir expressions 2013-11-22 21:41:59 +01:00
José Valim 5bd12f9cb9 Move lexical tracker to scope 2013-11-01 16:03:12 +01:00
José Valim f1e2fcf9f9 Same module variables must be explicitly shared
Prior to this commit, the following code would work:

    defmodule Hello do
      defmacro write do
        quote do
          a = 1
        end
      end

      defmacro read do
        quote do
          a
        end
      end
    end

    require Hello
    Hello.write
    Hello.read

Although this is convenient, it has many issues:

1. It is not clear at any point the intent of sharing the variables
   in between the macros

2. Whenever macros from the same module are nested, there is a chance
   a variable used before and after the nesting to be overriden

We address this issue by only allowing variables explicitly marked
with var! to be shared. Here is how the example above should be updated:

    defmodule Hello do
      defmacro write do
        quote do
          var!(a, Hello) = 1
        end
      end

      defmacro read do
        quote do
          var!(a, Hello)
        end
      end
    end

    require Hello
    Hello.write
    Hello.read
2013-10-30 16:15:19 +01:00
José Valim 992ac67512 Improve coverage for location: :keep 2013-10-30 16:15:19 +01:00
José Valim 404f77421a Refactor string interpolation to delegate to the tokenizer
This refactoring helps us clean up the interpolation code and
guarantee it works as expected since it goes under the same
tokenization rules. It also helps provide better sigil handling
(going to be improved in upcoming commits).
2013-10-25 13:19:47 +02:00
José Valim f8c66c8516 Remove unecessary vars cache 2013-09-24 13:21:58 +02:00
José Valim db47bd56b4 Add Path.relative_to_cwd and rely on it when generating stacktraces 2013-08-14 12:36:54 +02:00
José Valim 34b6e17a1b Fix shadowing warning in case with function, closes #1524 2013-08-02 13:04:03 +02:00
José Valim fc505f8a82 Replace ?is_new_atom macro by ?is_atom_start 2013-07-07 21:14:36 +02:00
José Valim 15c1a9891c Implement bindings in Elixir 2013-07-04 10:18:46 +02:00
José Valim 03323b9bfa Macro.escape should also escape nested tuples, closes #1344 2013-06-30 15:30:44 +02:00
José Valim 391fee3ea2 ^x variables should always refer to the value before the expression
Closes #1307
2013-06-21 18:27:16 +02:00
José Valim 5247961185 Optimize temp_vars lookup 2013-06-21 11:43:41 +02:00
José Valim bff8a6ae75 Remove deprecated code branches 2013-06-13 16:48:31 +02:00
José Valim fbb06f2086 Record each definition on tracker as soon as defined 2013-05-26 14:39:02 +02:00
José Valim d757f31ccd Unused functions with cyclic dependencies are now also warned as unused
Closes #1105
2013-05-25 00:14:37 +02:00
José Valim d9b98a62c8 Check if the module is in the same context before checking if it is open 2013-05-19 19:42:13 +02:00
José Valim e18c1602ba Only add quoted: true to required ast nodes 2013-05-13 15:56:15 -06:00
José Valim 02d0aa1d9a Deprecate var_context in favor of context 2013-05-13 15:56:15 -06:00
José Valim f38cf28cbd Store in the AST if contents come from a quoted expression
This provides a more robust way of checking from where
the original expressions are coming from compared to the
lexical check_clauses field we had in elixir_scope.

A direct consequence of this commit is that, the following
code:

    defrecord Sample, [:hello] do
      import List
    end

Now raises a warning if the List import is not used,
where it didn't previously.
2013-05-13 15:56:15 -06:00
José Valim b90b8d1385 Improve cons cell and other operators precedence, closes #862 2013-05-12 14:24:35 -06:00
José Valim c14ee51d15 Refactor elixir_quote to work on Elixir expressions
This allows us to re-use the code from Macro.escape,
reducing the duplication, and gives us more visibility
into the transformation process.
2013-05-04 14:31:58 -06:00
José Valim c125636535 Ensure the macro system respects imports hygiene, closes #875 2013-04-13 18:25:43 -07:00
José Valim b96c3c52ae Remove check_require in favor of a meta tag 2013-04-13 17:19:19 -07:00
José Valim f2e78d3d39 function(:is_atom, 1) is deprecated in favor of function(is_atom/1)
This is required so we can identity the proper function/arity
from quoting and properly hygienize function retrievals.
2013-04-13 17:19:19 -07:00
José Valim 6e8bcd9245 Update CHANGELOG 2013-03-10 18:12:50 -06:00
José Valim 28211b2714 Ensure aliases expansion also works for implicit aliases 2013-02-03 21:57:39 -07:00
José Valim cd51c80362 Tidy up and clean up quote API, closes #814 2013-02-03 12:14:18 -07:00
José Valim abb1ae981a Add hygienic imports to macros 2013-01-21 20:45:49 -07:00
José Valim 89cbe93bba The AST now allows metadata to be attached to each node
This means the second item in the AST is no longer an integer
(representing the line), but a keywords list. Code that relies
on the line information from AST or that manually generate AST
nodes need to be properly updated.
2013-01-21 15:42:03 -07:00
José Valim 4e651c8aae Expand aliases inside quote 2013-01-11 09:55:38 +01:00
José Valim eaa9714b3a Improve hygiene for variables, related to #722 2013-01-10 14:29:45 +01:00
Kim Shrier 54d74efa04 Update octal and hex escapes for characters, char lists, and strings to all accept
the same syntax and be case insensitive.  Also relocated the character type macros
into lib/elixir/include/elixir.hrl so that they didn't need to be defined in both
lib/elixir/src/elixir_interpolation.erl and lib/elixir/src/elixir_tokenizer.erl.
Added to the erlang and elixir unit tests to test the new syntax.
2012-12-23 20:05:23 -07:00
José Valim b32f6ef51f Keep variables in a single dictionary
This ensures we give the same treatment to quoted
and non-quoted variables.
2012-12-02 12:22:10 +01:00
José Valim 32764b3370 Copy all __ENV__ information on eval 2012-11-15 10:01:18 +01:00
José Valim 01f9518899 Keep user's given name when rebinding variables
The following code:

    counter = 1
    counter = 2

Is now rewritten internally to:

    counter   = 1
    counter@1 = 2

Which gives us a couple things:

1. Better debugging
2. We can now show warnings for rebound variables not used

Elixir also keeps `_@` prefix to store internal variables
(for example, `_@1`, `_@MODULE`, etc).

Closes #607.
2012-11-01 12:37:08 +01:00