Skip to content

unhelpful failed-to-parse error from get_source_expressions #552

@MichaelChirico

Description

@MichaelChirico

I had a stray = in the middle of a large file, the linting error was pretty arcane. MRE:

s <- '
foo(
  x,
  key = y["key"],
  = l$key
)'
writeLines(s, tmp <- tempfile())

Compare:

parse(tmp)
# Error in parse(tmp) : 
#   /tmp/Rtmpag3DPy/file33c5731c590bf5:5:3: unexpected '='
# 4:   key = y["key"],
# 5:   =
#      ^
lintr::get_source_expressions(tmp)
# Error in vapply(eq_assign_locs, next_with_parent, pc = pc, integer(1)) : 
#   values must be length 1,
#  but FUN(X[[1]]) result is length 0

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