andrewtimberlake / elixir-pdf

An attempt to get a nice API for PDF generation in Elixir
MIT License
77 stars 14 forks source link

Elixir 1.17 warnings #43

Open kevinkirkup opened 3 months ago

kevinkirkup commented 3 months ago

Seeing the flowing warnings with the new Elixir v1.17

warning: using map.field notation (without parentheses) to invoke function Pdf.Font.Helvetica.name() is deprecated, you must add parentheses instead: remote.function()
  (pdf 0.6.3) lib/pdf/fonts.ex:110: Pdf.Fonts.lookup_font/2
  (pdf 0.6.3) lib/pdf/fonts.ex:24: Pdf.Fonts.do_get_font/4
  (stdlib 6.0) gen_server.erl:2209: :gen_server.try_handle_call/4
  (stdlib 6.0) gen_server.erl:2238: :gen_server.handle_msg/6
  (stdlib 6.0) proc_lib.erl:329: :proc_lib.init_p_do_apply/3

warning: using map.field notation (without parentheses) to invoke function Pdf.Font.Helvetica.name() is deprecated, you must add parentheses instead: remote.function()
  (pdf 0.6.3) lib/pdf/font.ex:164: Pdf.Font.to_dictionary/2
  (pdf 0.6.3) lib/pdf/fonts.ex:118: Pdf.Fonts.load_font/2
  (pdf 0.6.3) lib/pdf/fonts.ex:24: Pdf.Fonts.do_get_font/4
  (stdlib 6.0) gen_server.erl:2209: :gen_server.try_handle_call/4
  (stdlib 6.0) gen_server.erl:2238: :gen_server.handle_msg/6
  (stdlib 6.0) proc_lib.erl:329: :proc_lib.init_p_do_apply/3

warning: using map.field notation (without parentheses) to invoke function Pdf.Font.Helvetica.name() is deprecated, you must add parentheses instead: remote.function()
  (pdf 0.6.3) lib/pdf/fonts.ex:126: Pdf.Fonts.load_font/2
  (pdf 0.6.3) lib/pdf/fonts.ex:24: Pdf.Fonts.do_get_font/4
  (stdlib 6.0) gen_server.erl:2209: :gen_server.try_handle_call/4
  (stdlib 6.0) gen_server.erl:2238: :gen_server.handle_msg/6
  (stdlib 6.0) proc_lib.erl:329: :proc_lib.init_p_do_apply/3

warning: using map.field notation (without parentheses) to invoke function Pdf.Font.Helvetica.name() is deprecated, you must add parentheses instead: remote.function()
  (pdf 0.6.3) lib/pdf/page.ex:237: anonymous fn/5 in Pdf.Page.annotate_attributed_text/3
  (elixir 1.17.1) lib/enum.ex:1703: Enum."-map/2-lists^map/1-1-"/2
  (pdf 0.6.3) lib/pdf/table.ex:189: Pdf.Table.chunk_col/2
  (pdf 0.6.3) lib/pdf/table.ex:183: Pdf.Table.chunk_cols/2
  (pdf 0.6.3) lib/pdf/table.ex:177: Pdf.Table.chunk_rows/5
  (pdf 0.6.3) lib/pdf/table.ex:40: Pdf.Table.table/5
  (pdf 0.6.3) lib/pdf/document.ex:125: Pdf.Document.table/5
  (pdf 0.6.3) lib/pdf.ex:529: Pdf.do_table/6
  (stdlib 6.0) gen_server.erl:2209: :gen_server.try_handle_call/4
  (stdlib 6.0) gen_server.erl:2238: :gen_server.handle_msg/6
  (stdlib 6.0) proc_lib.erl:329: :proc_lib.init_p_do_apply/3

...warning: using map.field notation (without parentheses) to invoke function Pdf.Font.Helvetica.name() is deprecated, you must add parentheses instead: remote.function()
  (pdf 0.6.3) lib/pdf/page.ex:467: anonymous fn/2 in Pdf.Page.print_attributed_line/2
  (elixir 1.17.1) lib/enum.ex:2531: Enum."-reduce/3-lists^foldl/2-0-"/3
  (pdf 0.6.3) lib/pdf/page.ex:448: Pdf.Page.print_attributed_lines/8
  (pdf 0.6.3) lib/pdf/page.ex:308: Pdf.Page.text_wrap/5
  (pdf 0.6.3) lib/pdf/table.ex:338: Pdf.Table.draw_row/4
  (pdf 0.6.3) lib/pdf/table.ex:299: Pdf.Table.draw_table/5
  (pdf 0.6.3) lib/pdf/table.ex:22: Pdf.Table.table/5
  (pdf 0.6.3) lib/pdf/document.ex:125: Pdf.Document.table/5
  (pdf 0.6.3) lib/pdf.ex:529: Pdf.do_table/6
  (stdlib 6.0) gen_server.erl:2209: :gen_server.try_handle_call/4
  (stdlib 6.0) gen_server.erl:2238: :gen_server.handle_msg/6
  (stdlib 6.0) proc_lib.erl:329: :proc_lib.init_p_do_apply/3
andrewtimberlake commented 3 months ago

Thanks for the bug report and attempted fix but the issue is a bit more complex than that. In fact the underlying implementation relies on the fact that module.name can be a function call or a field access because external fonts are struct instances with fields and internal fonts are modules with functions.

This has other problems so I’m going to have to work on a better implementation to fix this properly.

dinhhuydh commented 1 month ago

@andrewtimberlake Are you working on the new implementation to fix the warning?