diff --git a/lib/ast.js b/lib/ast.js index e2d7240a3..77fde28a5 100644 --- a/lib/ast.js +++ b/lib/ast.js @@ -4219,6 +4219,9 @@ exports.Label = Label = (function(superclass){ var fun; this.label = label || '_'; this.it = it; + if (this.it.curried) { + this.carp("can't use label with a curried function (attempted label '" + this.label + "')"); + } if (fun = (it instanceof Fun || it instanceof Class) && it || it.calling && it.it.head) { fun.name || (fun.name = this.label, fun.labeled = true); return it; diff --git a/src/ast.ls b/src/ast.ls index fe66ffffe..86d873622 100644 --- a/src/ast.ls +++ b/src/ast.ls @@ -2674,6 +2674,7 @@ class exports.If extends Node # A labeled block or statement. class exports.Label extends Node (@label or \_, @it) -> + @carp "can't use label with a curried function (attempted label '#{@label}')" if @it.curried if fun = it instanceof [Fun, Class] and it or it.calling and it.it.head fun.name or fun <<< {name: @label, +labeled} diff --git a/test/compilation.ls b/test/compilation.ls index 5a12ddd65..01c395ad4 100644 --- a/test/compilation.ls +++ b/test/compilation.ls @@ -35,6 +35,7 @@ compileThrows 'unmatched `]`' 3 '[{\n\n]}' compileThrows 'missing `)CALL`' 1 'f(' +compileThrows "can't use label with a curried function (attempted label 'abc')" 1 ':abc (a, b) --> a + b' throws ''' empty range on line 1