Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Confusing type error for typos #4

Open
Timmmm opened this issue Nov 28, 2023 · 2 comments
Open

Confusing type error for typos #4

Timmmm opened this issue Nov 28, 2023 · 2 comments

Comments

@Timmmm
Copy link

Timmmm commented Nov 28, 2023

Unfortunate that Asciidoctor is written in a dynamically typed language. If you make a typo like this:

sail::execute[clause="AIUPC(_, _)",part=body,unindent]

You get this helpful error:

/usr/lib/ruby/gems/3.1.0/gems/asciidoctor-sail-0.2/lib/asciidoctor-sail/macros.rb:41:in `read_source': asciidoctor: FAILED: /foo.adoc: Failed to load AsciiDoc document - no implicit conversion of String into Integer (TypeError)
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-sail-0.2/lib/asciidoctor-sail/macros.rb:145:in `get_source'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-sail-0.2/lib/asciidoctor-sail/macros.rb:210:in `process'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/parser.rb:662:in `[]'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/parser.rb:662:in `next_block'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/parser.rb:397:in `next_section'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/parser.rb:382:in `next_section'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/parser.rb:382:in `next_section'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/parser.rb:382:in `next_section'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/parser.rb:97:in `parse'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/document.rb:538:in `parse'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/load.rb:84:in `load'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:78:in `convert'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:190:in `block in convert_file'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:190:in `open'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/convert.rb:190:in `convert_file'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/cli/invoker.rb:129:in `block in invoke!'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/cli/invoker.rb:112:in `each'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-2.0.18/lib/asciidoctor/cli/invoker.rb:112:in `invoke!'
        from /usr/lib/ruby/gems/3.1.0/gems/asciidoctor-pdf-2.3.7/bin/asciidoctor-pdf:46:in `<top (required)>'
        from /usr/bin/asciidoctor-pdf:25:in `load'
        from /usr/bin/asciidoctor-pdf:25:in `<main>'
@Alasdair
Copy link
Owner

Alasdair commented Dec 8, 2023

Yes, this is unfortunate. I think I need to do some more validation. I also don't really know how an asciidoctor plugin is supposed to nicely report errors.

For some things I had to dive into he asciidoctor source to figure out what was going on, which can be quite fun when the method you are looking for is being dynamically generated at runtime and there's therefore nothing you can even grep for. Ruby is interesting 😄

@Timmmm
Copy link
Author

Timmmm commented Dec 18, 2023

For some things I had to dive into he asciidoctor source to figure out what was going on, which can be quite fun when the method you are looking for is being dynamically generated at runtime and there's therefore nothing you can even grep for. Ruby is interesting

Ouch yes. Maximum respect for powering through! I was also looking at some Ruby code recently (Gitlab) and ran into the exact same issue. There are some identifiers that are simply not defined anywhere. They must be dynamically generated but I eventually gave up looking.

It's like dynamic typing but even worse!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants