agentjido / agentjido/term_ui

Cannot inject attribute because it contains a reference

Open
#7 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Elixir
Stars
205
Forks
16
Avg merge
27m
Merged PRs (30d)
5

Description

Hello! I really like your project!

I'm getting a compilation error as follows when trying to build it:


     warning: storing and reading regexes from module attributes is deprecated, inline the regex inside the function definition instead
     │
 855 │     case Regex.run(@timestamp_pattern, line) do
     │     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     │
     └─ lib/term_ui/widgets/log_viewer.ex:855: TermUI.Widgets.LogViewer.extract_timestamp/1


== Compilation error in file lib/term_ui/widgets/log_viewer.ex ==
** (ArgumentError) cannot inject attribute @level_patterns into function/macro because ~r/\b(EMERGENCY|EMERG)\b/i contains a reference (#Reference<0.542768475.64618511.175429>) and therefore it cannot be escaped (it must be defined within a function instead). The supported values are: lists, tuples, maps, atoms, numbers, bitstrings, PIDs and remote functions in the format &Mod.fun/arity
    (elixir 1.19.0-rc.0) lib/kernel.ex:3878: Kernel.do_at_escape/2
    (elixir 1.19.0-rc.0) expanding macro: Kernel.@/1
    lib/term_ui/widgets/log_viewer.ex:868: TermUI.Widgets.LogViewer.extract_level/1

Environment

Elixir 1.19.0
Erlang/OTP 28
FreeBSD 14.2

Steps to reproduce

git clone https://github.com/pcharbon70/term_ui
cd term_ui
mix deps.get
mix compile

Any idea what I might need to do to get it going? Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported mix compile reproduction on Elixir 1.19/OTP 28, then inspect lib/term_ui/widgets/log_viewer.ex around extract_timestamp/1 and extract_level/1, especially the module attributes named in the error. Done means the project compiles successfully without the reported attribute-injection error.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.