Commit Graph
51 Commits
Author SHA1 Message Date
Ivan Kozik 53acbc7ac2 Fix more typos and spelling errors (#6530) 2017-09-01 10:20:53 +02:00
José Valim ad4880ab98 Always use in_context definition for struct expansion, closes #6409 2017-07-31 06:39:26 +02:00
José Valim 710dd2b012 Do not remove structs syntax in Elixir pass 2017-05-20 20:50:54 +02:00
Michał Muskała d8d412cbf2 Make sure System.stracktrace is first thing done in the handler (#6119)
If any of the functions catches an error, we'd get a wrong trace
2017-05-18 12:27:17 +02:00
Andrea Leopardi 159f9d3328 Warn when a :__struct__ key is used when building/updating structs (#6113)
Until now, "%x{__struct__: y}" would ignore the ":__struct__" part and only
use/match on "x", without warnings. With this commit, a warning is emitted in
this case and in the respective case when updating ("%SomeStruct{x | __struct__:
y}").
2017-05-15 20:56:02 +02:00
José Valim 7f8214ebfd Remove warnings on OTP 20 2017-05-07 10:28:08 +02:00
José Valim 5cef69c7e6 Clarify docs 2017-03-15 16:04:36 +01:00
José Valim 922139da50 Solve race conditions on struct dispatch 2017-03-15 15:46:52 +01:00
José Valim f37c4e001f Add prematch_vars 2017-02-23 10:43:09 +01:00
Andrea Leopardi fbbc38584a Replace elixir_errors:compile_error/4 with form_error/4 in elixir_map 2017-02-20 13:24:24 +01:00
Aleksei Magusev 30ba2c8527 Rename elixir_exp module to elixir_expand 2017-02-19 21:57:50 +01:00
Aleksei Magusev c1c009537a Rename m/2 helper macro to key/2 in the main header file 2017-02-19 21:56:05 +01:00
José Valim f9d46d9145 Split erl and ex passes in elixir_def 2017-02-19 13:01:13 +01:00
José Valim b3a75a079f Unify local handling in elixir_def 2017-02-18 23:36:30 +01:00
José Valim 7ef7f8b331 Perform map_key check on elixir_exp 2017-02-15 20:44:06 +01:00
José Valim 05b12a5c0f Move maps/structs validation to elixir pass 2017-02-14 14:34:22 +01:00
Gal Tsubery 3cbd2ad29c Fix translation of maps used as map keys (#5654)
Fixes [issue 5602](https://github.com/elixir-lang/elixir/issues/5602)
Erlang does not accept map_field_exact tag for map used as map keys
since it does not perform any matching on map keys.

For example this fails:
$ erl
Erlang/OTP 19 [erts-8.2] [source-a2c5a92] [64-bit] [smp:8:8]
[async-threads:10] [hipe] [kernel-poll:false]

Eshell V8.2  (abort with ^G)
1> #{ #{1 => X} := 3 } = #{ #{1 => 2} => 3 }.
* 1: illegal map key in pattern
2017-01-15 01:56:28 +01:00
Michał Muskała 10b63eb8af Use Macro.to_string/1 when printing bad struct keys (#5403) 2016-11-03 12:25:18 +01:00
Michał Muskała 3f25c3ce9b Make sure bad remote call errors have file/line info (#5116)
Change how we mark the generated AST for suppressing dialyzer errors -
instead of [generated: true, location: 0], we provide proper line number.
This means, however, that on OTP 18, those nodes won't be recognized
as generated and warnings will be issued.
It was decided that proper error messages are more important than
avoiding bogus dialyzer warnings.
The old mark for generated code is left in places that made compiler
issue warnings on 18.

The bad remote call dialyzer warnings can be suppressed with the
@dialyzer :no_fail_call
module attribute.
2016-08-15 13:18:09 +01:00
Michał Muskała 6dfe70c57a Mark struct update syntax as generated (#5067)
With changes to OTP 19, dialyzer started emitting warnings for
the struct update syntax where variable could only be that struct.
For example:

    def foo(%Foo{} = struct), do: %Foo{struct | bar: :baz}
2016-07-27 11:26:45 +02:00
José Valim dd0a844a1a Ensure structs can be expanded in dynamic module names, closes #4894 2016-06-28 10:30:15 +01:00
Eric Entin 82dd9ad277 Make sure struct expansion results in a remote dispatch (#4807) 2016-06-12 23:38:51 +02:00
José Valim 42deb43fa1 Add @enforce_keys to defstruct, defexception and friends 2016-05-26 13:26:58 +02:00
José Valim a07b02c220 Add struct expansion via __struct__/1 2016-05-26 12:40:12 +02:00
José Valim 890ecc83eb Tidy up LexicalTracker 2016-05-18 08:42:33 +02:00
eksperimental 685e87bdf0 Formmating: Add white space around vertical bar (#4507) 2016-04-25 00:55:49 +02:00
José Valim 0096354632 Allow variable struct names when matching 2016-02-21 14:19:57 +01:00
José Valim 80557a6b1f Improvements to the parallel compiler
In previous versions, when trying to compile a file and the file
depended on a module that was not yet compiled or was unavailable,
the parallel compiler would wait until the missing dependency shows
up. In case it did not, the compiler would "release" the file being
compiled, disabling any further missing dependency resolution.

This lead to issues in code like the following:

    Code.ensure_compiled(SomeModuleThatWontBeAvailable)
    %SomeStructFromMyProject{}

Because `SomeModuleThatWontBeAvailable` would never be available,
the file above would block until released. When released, the
parallel compiler would disable further lookups for that file,
meaning we would no longer wait for missing dependencies when we
attempt to load the struct.

In the majorify of cases, the struct would already be available,
which meant compilation would work. But if the file that defined
the struct was also blocked by the compiler (and consequently
released), compilation would be non-deterministic.

This patch solves the issue by removing the "release" behaviour
from the compiler. If a dependency is not available, we will
notify the file of such and move on, with the parallel compiler
still enabled. In order to guarantee this works without
introducing deadlocks, the parallel compiler now also knows which
module is being defined by a given file, building a graph and
solving dependencies from the leaves. In case it is a cyclic
graph, we will raise that a deadlock was found.

Closes #4294
Closes #4055
2016-02-13 14:15:18 +01:00
José Valim 913ca994f3 Add generated annotations 2015-10-11 12:02:47 -05:00
José Valim 1f08ef598d Ensure we list structs and requires as compile time deps 2015-09-24 12:35:53 +02:00
eksperimental f9bcdd5c1c Add space after comma: Format consistently 2015-03-17 22:55:27 +07:00
José Valim 3d98684f12 Improve error message with invalid structures in maps
Closes #2958
2015-01-27 17:43:22 +01:00
José Valim add5b12e61 Improve error message for undefined struct 2014-08-13 09:19:26 +02:00
José Valim 7a8c9909b3 Avoid race conditions in the struct detection 2014-08-01 23:58:02 +02:00
José Valim 64bcf0d642 Improve error message for struct expansion in invalid contexts 2014-07-01 12:41:27 +02:00
José Valim 9bc8925018 Ensure defrecord and defstruct executes its args 2014-05-07 14:39:19 +02:00
José Valim b0a5197f42 Convert ExUnit.Test and ExUnit.TestCase to structs 2014-05-06 22:24:03 +02:00
José Valim fdf53787cf Remove unecessary .hrl macros 2014-04-30 19:24:04 +02:00
José Valim c435dbe38d Convert #elixir_env to a struct too 2014-04-30 16:32:13 +02:00
Eric Meadows-Jönsson c6dc65c418 Fix compiler crash for some map literals 2014-04-22 18:29:54 +02:00
José Valim 56f15d9f4e Do not add spaces after { and before }
This makes the source code consistent with the result
returned by inspect/2.
2014-04-21 19:06:35 +02:00
José Valim 845a3d1fea Make defstruct work on quoted expressions, closes #2156 2014-04-10 11:41:11 +02:00
José Valim 75de306c46 Make the ParallelCompiler aware of missing structs
This allows modules that have recursive dependencies on structs
to be defined by having a fine grained control on the struct
definition besides the module one.
2014-03-02 16:24:45 +01:00
José Valim 17b4dbbdbb Ensure struct fields are properly escaped when injected into AST 2014-03-01 23:41:14 +01:00
José Valim 00b1aadd76 Add a __struct__ field on defstruct and ensure proper message on struct body access 2014-02-28 17:30:24 +01:00
José Valim 10b1f56ad9 Ensure structs can be used on pattern matching 2014-02-27 16:30:11 +01:00
José Valim 128d82fde6 Add defstruct and allow unquoting inside maps/structs 2014-02-19 22:35:09 +01:00
José Valim 20b14b3221 Ensure structs can be access from context modules 2014-02-16 13:49:34 +01:00
José Valim dd4ede4c1d Only access public __struct__ function 2014-02-16 13:29:31 +01:00
José Valim 99e69bd6c5 Support structs special forms 2014-02-06 12:30:14 +01:00