Commit Graph
34 Commits
Author SHA1 Message Date
Michał Muskała e24b7c6659 Use Macro.to_string/1 when printing bad struct keys (#5403) 2016-11-03 12:25:18 +01:00
Michał Muskała 8277dcd776 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 270c983b13 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 b98b4bd235 Ensure structs can be expanded in dynamic module names, closes #4894 2016-06-28 10:30:15 +01:00
Eric Entin 2d7017fcc7 Make sure struct expansion results in a remote dispatch (#4807) 2016-06-12 23:38:51 +02:00
José Valim c87a7dbf26 Add @enforce_keys to defstruct, defexception and friends 2016-05-26 13:26:58 +02:00
José Valim dabe5e5102 Add struct expansion via __struct__/1 2016-05-26 12:40:12 +02:00
José Valim b38ace0a79 Tidy up LexicalTracker 2016-05-18 08:42:33 +02:00
eksperimental 4ceb41e71b Formmating: Add white space around vertical bar (#4507) 2016-04-25 00:55:49 +02:00
José Valim d1d81af7c0 Allow variable struct names when matching 2016-02-21 14:19:57 +01:00
José Valim b6dc389f5e 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 3ccd5137ef Add generated annotations 2015-10-11 12:02:47 -05:00
José Valim 94c3f89e37 Ensure we list structs and requires as compile time deps 2015-09-24 12:35:53 +02:00
eksperimental 61675c3ea8 Add space after comma: Format consistently 2015-03-17 22:55:27 +07:00
José Valim adc9498c81 Improve error message with invalid structures in maps
Closes #2958
2015-01-27 17:43:22 +01:00
José Valim 1ed99d4ac7 Improve error message for undefined struct 2014-08-13 09:19:26 +02:00
José Valim 3b34a57bd2 Avoid race conditions in the struct detection 2014-08-01 23:58:02 +02:00
José Valim 15bf309760 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
José Valim daa0049b32 Move map and struct functionality to elixir_map 2014-02-05 17:37:16 +01:00