Skip to content

groovy func_start: MarkupBuilder/Jenkins-DSL trailing-closure calls misdetected as zero-prefix method definitions #2530

Closed

Description

@squid-protocol

Summary

Found during tri-comparison manual verification of groovy (tree-sitter has no usable
grammar for this language -- see separate note below). func_start's branch 2 (the
zero-modifier-prefix branch, needed to match real bare constructors like
MyClass(String arg) {) is syntactically indistinguishable from a very common Groovy
idiom: calling a method with a named-argument map plus a trailing closure --
a(href: "x", class: "y") { ... }, button(name: "clear") { ... }, l.layout(title: "...") { ... }. This is the standard Groovy MarkupBuilder/NodeBuilder DSL shape
(used pervasively in Jenkins's own .groovy view templates, which replaced Jelly) and
also shows up in Jenkins Pipeline DSL steps (stage, node, dir, timeout) and
Gradle DSL blocks -- none of these are function definitions.

Evidence

Confirmed against the language-crucible/data/groovy/jenkins_view_groovy/ corpus (29
files): 57 of GitGalaxy's 718 total named functions across the whole groovy corpus
(~8%) come from this one folder, and essentially all of them are DSL/builder calls
misread as definitions, not real code:

div|9    span|7    li|7    a|7    ul|4    stage|4   section|4
node|3   withChecks|2  dir|2  Unknown_Block|2  timeout|1  table|1
recordIssues|1  realtimeJUnit|1  form|1  button|1

Two entries fall back to the generic Unknown_Block name entirely (_extract_name
can't find a usable token) for the qualified form of the same shape:

  • jenkins_view_groovy/hudson_model_EnvironmentContributor_EnvVarsHtml_index.groovy:10
    -- l.layout(title: _("..."), type: 'one-column') {
  • jenkins_view_groovy/jenkins_management_AsynchronousAdministrativeMonitor_log.groovy:31
    -- l.main_panel() {

Concrete example (hudson_triggers_SlowTriggerAdminMonitor_message.groovy:13):

button(name: "clear", type: "submit", class: "jenkins-button jenkins-submit-button jenkins-button--primary") {
    raw _("Dismiss")
}

This is a call to a dynamically-dispatched button builder method (Groovy
methodMissing-backed MarkupBuilder), passing a named-argument map and a trailing
closure -- not a function/method declaration. func_start's branch 2 already excludes
a hand-picked list of known Gradle DSL keywords (task, project, dependencies,
...) for exactly this reason, but an arbitrary builder/tag method name (div, a,
button, li, ...) can't be enumerated the same way -- the set of possible builder
tag names is unbounded.

Why this wasn't fixed in the same pass

Unlike the three groovy bugs fixed in # (a genuinely-empty
class_start capture group, an unshielded Prism gap for """/''' multi-line
strings, and a def-as-bare-name branch-2 collision), this one is a real grammar
ambiguity, not a deterministic defect -- Groovy's own syntax makes "bare zero-prefix
call with a trailing closure" and "bare zero-prefix declaration" look identical at the
lexical level. A correct fix needs either (a) a curated denylist of common
HTML/XML-tag-shaped builder names (fragile, incomplete by construction), or (b) a
smarter heuristic (e.g., a named-argument map as the first/only parameter is a strong
builder-call signal a real constructor rarely has) that needs its own design pass and
full-corpus verification, not a drive-by regex tweak.

Suggested next step

Investigate whether branch 2 can be tightened to exclude the "named-argument-map
first parameter" shape (identifier(word: ..., ...)) without also rejecting
legitimate bare constructors that happen to take one, and re-run the recall audit
against the full crucible corpus to confirm the fix doesn't trade these false
positives for new false negatives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope:frontier

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions