Skip to content

Macro error with Crystal version 1.16 #30

@russ

Description

@russ

I created a minimal example to show the error.
https://github.com/russ/shrine-failure-example/tree/master

Seems to be something with the plugin macros?

require "shrine"
require "shrine/plugins/determine_mime_type"

module Uploads
  class Uploader < Shrine
    load_plugin(
      Shrine::Plugins::DetermineMimeType,
      analyzer: Shrine::Plugins::DetermineMimeType::Tools::File
    )

    finalize_plugins!

    def generate_location(_io : IO | UploadedFile, metadata, **options)
      "/tmp/example"
    end
  end
end

file = File.open("shard.yml")
Uploads::Uploader.upload(file, "store")
❯ crystal example.cr 
Showing last frame. Use --error-trace for full trace.

In lib/shrine/src/shrine.cr:141:30

 141 | {% for plugin in @type.constant(:PLUGINS) %}
                              ^-------
Error: `for` expression must be an array, hash, tuple, named tuple or a range literal, not NilLiteral:

nil

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions