Giter Club home page Giter Club logo

erlex's People

Contributors

asummers avatar evnu avatar jeremyjh avatar kianmeng avatar pragtob avatar smaximov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

erlex's Issues

Warnings on Elixir 1.16+ (?)

While upgrading our app, I stumbled upon these warnings:

warning: in order to compile .yrl files, you must add "compilers: [:yecc] ++ Mix.compilers()" to the "def project" section of erlex's mix.exs
  (mix 1.16.2) lib/mix/tasks/compile.yecc.ex:70: Mix.Tasks.Compile.Yecc.preload/1
  (mix 1.16.2) lib/mix/compilers/erlang.ex:66: Mix.Compilers.Erlang.compile/6
  (mix 1.16.2) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
  (mix 1.16.2) lib/mix/tasks/compile.all.ex:124: Mix.Tasks.Compile.All.run_compiler/2
  (mix 1.16.2) lib/mix/tasks/compile.all.ex:104: Mix.Tasks.Compile.All.compile/4
  (mix 1.16.2) lib/mix/tasks/compile.all.ex:93: Mix.Tasks.Compile.All.with_logger_app/2

warning: in order to compile .xrl files, you must add "compilers: [:leex] ++ Mix.compilers()" to the "def project" section of erlex's mix.exs
  (mix 1.16.2) lib/mix/tasks/compile.leex.ex:69: Mix.Tasks.Compile.Leex.preload/1
  (mix 1.16.2) lib/mix/compilers/erlang.ex:66: Mix.Compilers.Erlang.compile/6
  (mix 1.16.2) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
  (mix 1.16.2) lib/mix/tasks/compile.all.ex:124: Mix.Tasks.Compile.All.run_compiler/2
  (mix 1.16.2) lib/mix/tasks/compile.all.ex:104: Mix.Tasks.Compile.All.compile/4
  (mix 1.16.2) lib/mix/tasks/compile.all.ex:93: Mix.Tasks.Compile.All.with_logger_app/2

==> erlex
Compiling 2 files (.erl)
Compiling 1 file (.ex)
Generated erlex app

Opening this so we can discuss it!

Pretty-printing multiple contract heads

When multiple contract heads are encountered, the output would be more reasonable if newline separated the contract heads.

Example from pretty_print_test.exs

expected_output =
  "Contract head: (any(), nil) :: nilContract head: (Ecto.Queryable.t(), String.t()) :: String.t()"

I believe this to be more readable if it includes an additional newline:

expected_output =
  "Contract head: (any(), nil) :: nil\nContract head: (Ecto.Queryable.t(), String.t()) :: String.t()"

Deprecated warning during compile

Using Elixir 1.8.0 on OTP 21.2.2

==> erlex
Compiling 2 files (.erl)
/usr/lib64/erlang/lib/parsetools-2.1.5/include/yeccpre.hrl:60: Warning: erlang:get_stacktrace/0: deprecated; use the new try/catch syntax for retrieving the stack backtrace
Compiling 1 file (.ex)
Generated erlex app

Pretty Printing Spec With When

This code fails on dialyxir master. It looks like we just need to keep a space after "when" in the spec we pass to the code formatter from pretty_print_contract, Code.format_string! is complaining about 'ok'whenone.

defmodule WhatTheSpec do
  @type key :: atom()
  @type transaction :: map()

  def put(_, _, _ \\ nil)

  @spec put(one, key(), any()) :: transaction() when one: transaction()
  def put(t, _, _) when is_map(t), do: t

  @spec put(one, any(), Keyword.t()) :: :ok when one: key()
  def put(_, _, _), do: :ok

  @spec put_foo(any()) :: :ok
  def put_foo(value) do
    put(:foo, value, nil) # note the explicit nil here
  end
end

'(one,key(),any()) -> transaction() when one :: transaction();(one,any(),\'Elixir.Keyword\':t()) -> \'ok\' when one :: key()'
%SyntaxError{
  description: "syntax error before: whenone",
  file: "nofile",
  line: 1
}
** (throw) {:error, :formatting, "@spec a(:one, any(), Keyword.t()) :: 'ok'whenone :: key()\ndef a() do\n  :ok\nend\n"}

Type related issue

Nothing big, just noticing a potential couple bugs as I was running a new BEAM typer (it's a negative ML typer, not a weak positive typer like Dialyzer, Gradualizer, would make for an awesome addition into Dialyxir so I don't have to publish and keep up Gradualixir ^.^) over one of my projects and erlex had a couple things pop up that aren't entirely, though some are it's fault:

_build/test/lib/erlex/ebin/Elixir.Erlex.beam: The variable _byte@1 on line 269 is expected to have type integer() but it has type term()
_build/test/lib/erlex/ebin/Elixir.Erlex.beam: The pattern [61, 58, 61] on line 0 does not have type:
infix :: 'Elixir.String':t()
_build/test/lib/erlex/ebin/Elixir.Erlex.beam: The pattern [112, 97, 116, 116, 101, 114, 110, 32 | _rest@1] on line 0 does not have type:
pattern :: 'Elixir.String':t()

_build/test/lib/erlex/ebin/parser.beam: The pattern {ok, [{atom, _, Symbol}], _} on line 74 doesn't have the type {error,
           ErrorInfo :: error_info(),
           non_neg_integer() | {line(), column()}} |
          {ok,
           Tokens :: tokens(),
           non_neg_integer() | {line(), column()}}

And the lexer.erl file is fine.

In essence it's saying that:

  • The lib/erlex.ex file line 269 the byte in the expression of <<byte::8>> is supposed to have type integer, but it can potentially be any type, and thus can potentially fail, however that's because Elixir's Enum.into/3 isn't typespec'd properly, so that's entirely Elixir's fault.

  • The lib/erlex.ex file on (not actually line 0) https://github.com/asummers/erlex/blob/master/lib/erlex.ex#L73 it has the line def pretty_print_infix('=:='), do: "===" but it's typespec'd as @spec pretty_print_infix(infix :: String.t()) :: String.t() and Elixir's String.t() type is typespec'd as https://github.com/elixir-lang/elixir/blob/v1.9.2/lib/elixir/lib/string.ex#L213 :

    @type t :: binary

    And thus the character list is not a binary, hence it's failing (isn't dialyzer itself catching this one?!).

  • Same thing again on line https://github.com/asummers/erlex/blob/master/lib/erlex.ex#L96 with def pretty_print_pattern('pattern ' ++ rest) do when it's typespec'd as @spec pretty_print_pattern(pattern :: String.t()) :: String.t() binaries.

  • As for the parser file, no clue where it is complaining about, but it's missing a failure case and the success case is too tightly bound.

This was mostly just for fun, and the fact erlex only has 4 issues reported unlike the 4000 that most other libraries have. ^.^;

Handle empty tuples

Empty tuples are a thing, and this doesn't deal with them. I don't know how they're useful, but they're legal so we should parse them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.