-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
kind:bugA bug in the code. Does not apply to documentation, specs, etc.A bug in the code. Does not apply to documentation, specs, etc.topic:compiler:semantic
Description
Bug Report
Minimal example
require "log"
Log.setup level: :trace
log = Log.for "testing"
log.error &.emit "test", does: {"this": :work?}
# symbol is not compatible ^^^^^^Expected behavior
An error message at compilation about the symbol :work? being incompatible with Log::Metadata::Value
Actual behavior
An undesirably vague error message at compile time
In /usr/lib/crystal/log/metadata.cr:202:27
202 | def initialize(hash : NamedTuple | Hash)
^---------
Error: can't use NamedTuple(T) in unions yet, use a more specific type
with trace
In src/test.cr:8:5
8 | log.error &.emit "test", does: {"this": :work?}
^----
Error: instantiating 'Log#error()'
In src/test.cr:8:5
8 | log.error &.emit "test", does: {"this": :work?}
^----
Error: instantiating 'Log#error()'
In src/test.cr:8:13
8 | log.error &.emit "test", does: {"this": :work?}
^---
Error: instantiating 'Log::Emitter#emit(String)'
In /usr/lib/crystal/log/main.cr:194:7
194 | emit(message, kwargs)
^---
Error: instantiating 'emit(String, NamedTuple(does: NamedTuple(this: Symbol)))'
In /usr/lib/crystal/log/main.cr:198:55
198 | Entry.new(@source, @severity, message, Metadata.build(data), @exception)
^----
Error: instantiating 'Log::Metadata.class#build(NamedTuple(does: NamedTuple(this: Symbol)))'
In /usr/lib/crystal/log/metadata.cr:60:14
60 | Metadata.new(nil, value)
^--
Error: instantiating 'Log::Metadata.class#new(Nil, NamedTuple(does: NamedTuple(this: Symbol)))'
In /usr/lib/crystal/log/metadata.cr:36:10
36 | data.setup(parent, entries)
^----
Error: instantiating 'Log::Metadata#setup(Nil, NamedTuple(does: NamedTuple(this: Symbol)))'
In /usr/lib/crystal/log/metadata.cr:46:15
46 | entries.each_with_index do |key, value, i|
^--------------
Error: instantiating 'NamedTuple(does: NamedTuple(this: Symbol))#each_with_index()'
In /usr/lib/crystal/named_tuple.cr:567:5
567 | each do |key, value|
^---
Error: instantiating 'each()'
In /usr/lib/crystal/named_tuple.cr:567:5
567 | each do |key, value|
^---
Error: instantiating 'each()'
In /usr/lib/crystal/log/metadata.cr:46:15
46 | entries.each_with_index do |key, value, i|
^--------------
Error: instantiating 'NamedTuple(does: NamedTuple(this: Symbol))#each_with_index()'
In /usr/lib/crystal/log/metadata.cr:47:50
47 | ptr_entries[i] = {key: key, value: Value.to_metadata_value(value)}
^----------------
Error: instantiating 'Log::Metadata::Value.class#to_metadata_value(NamedTuple(this: Symbol))'
In /usr/lib/crystal/log/metadata.cr:216:42
216 | value.is_a?(Value) ? value : Value.new(value)
^--
Error: instantiating 'Log::Metadata::Value.class#new(NamedTuple(this: Symbol))'
In /usr/lib/crystal/log/metadata.cr:204:12
204 | hash.each do |key, value|
^---
Error: instantiating 'NamedTuple(this: Symbol)#each()'
In /usr/lib/crystal/log/metadata.cr:204:12
204 | hash.each do |key, value|
^---
Error: instantiating 'NamedTuple(this: Symbol)#each()'
In /usr/lib/crystal/log/metadata.cr:205:31
205 | raw[key.to_s] = Value.to_metadata_value(value)
^----------------
Error: instantiating 'Log::Metadata::Value.class#to_metadata_value(Symbol)'
In /usr/lib/crystal/log/metadata.cr:202:27
202 | def initialize(hash : NamedTuple | Hash)
^---------
Error: can't use NamedTuple(T) in unions yet, use a more specific type
Other info
Crystal version
$ crystal --version
Crystal 1.6.0 (2022-10-10)
LLVM: 14.0.6
Default target: x86_64-pc-linux-gnuOS Version
$ uname -sor
Linux 5.19.13-arch1-1 GNU/Linuxento
Metadata
Metadata
Assignees
Labels
kind:bugA bug in the code. Does not apply to documentation, specs, etc.A bug in the code. Does not apply to documentation, specs, etc.topic:compiler:semantic