question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect position of error reported from macro in inline methods chain

See original GitHub issue

This issue is based on scalameta/metals#3214

The position of error that was produced in inline context is unwrapped to the outermost one. In case if it’s a chain of inline calls, it’s unclear where the actual error happens.

Example:

// InlineMac.scala
object InlineMac:
  
  inline def sample(inline expr: String): Int =
    ${ sampleImpl('expr) }
  
  def sampleImpl(expr: Expr[String])(using Quotes): Expr[Int] =
      import quotes.reflect.*
      report.errorAndAbort("Error", expr)
      
// Main.scala
object Main:
  def main(args: Array: String): Unit =
     inline def v2 = InlineMac.sample("foo")  // <- the actual error position was here
     inline def v1 = v2
     
     v2  // [error] Error <- reported error position is here - wrong

There is a difference between in error message between direct compiler usage and using bsp-client. The default compiler reportee additionally adds lines like: This location contains code that was inlined from Main.scala:27 but I don’t think that it helps a lot in this case.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dos65commented, Jan 13, 2022

@tgodzik The plan was to extend the diagnostic structure to carry this additional info for inline error, but I haven’t had time to prototype this thing yet.

0reactions
deusaquiluscommented, Jan 13, 2022

Thanks for all your work @nicolasstucki, @dos65 and @tgodzik! Being able to display error underlines on specific terms is super exciting for me!

Read more comments on GitHub >

github_iconTop Results From Across the Web

VBA Error Handling - A Complete Guide - Excel Macro Mastery
Compilation errors occur over more than one line. The syntax is correct on a single line but is incorrect when all the project...
Read more >
Crate error_chain - Docs.rs
A library for consistent and reliable error handling. error-chain makes it easy to take full advantage of Rust's powerful error handling features without ......
Read more >
Weird macro recursive inline limit infinite loop bug/crash #11730
I have made the issue circe/circe#1695, which is about the useless error message their macro code generates in a given scenario – it's...
Read more >
C Preprocessor Macro with 2 arguments issue - Stack Overflow
This function formats the message and reports it on standard error, determining time and date if appropriate. It also exits (hence the _Noreturn ......
Read more >
List of the armcc error and warning messages - Arm Developer
The ARM Compiler Errors and Warnings Reference Guide provides lists of the errors and warnings that each of the compilation tools can generate....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found