Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

LTA error message for mistaken uses of '.' for concatenation in Rakudo #2166

Closed p6rt closed 11 years ago

p6rt commented 14 years ago

Migrated from rt.perl.org#77856 (status was 'resolved')

Searchable as RT77856$

p6rt commented 14 years ago

From @masak

\ std​: "foo" . "bar" \ std 32123​: OUTPUTĀ«===SORRY!===ā¤Unsupported use of . to concatenate strings; in Perl 6 please use ~ [...] Parse failedā¤FAILED 00​:01 115mā¤Ā» \ rakudo​: "foo" . "bar" \ rakudo c71489​: OUTPUTĀ«===SORRY!===ā¤Confused [...] * masak submits LTA rakudobug

p6rt commented 11 years ago

From @timo

I made a patch that fixes this​:

  > "foo"."bar"   Quoted method name requires parenthesized arguments. If you meant to concatenate two strings, use '~'.   > "foo" . "bar"   Unsupported use of . to concatenate strings; in Perl 6 please use ~

I'm wondering, if a testcase should be written to check for a helpful error message? Would this kind of thing go in t/spec somehow?

p6rt commented 11 years ago

From @timo

0001-warn-about-obsolete-use-of-.-to-concatenate-strings.patch ```diff From 1d8320e1037855e9a90f987ec6649cc73247e60d Mon Sep 17 00:00:00 2001 From: Timo Paulssen Date: Thu, 13 Dec 2012 00:33:44 +0100 Subject: [PATCH] warn about obsolete use of . to concatenate strings. --- src/Perl6/Grammar.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Perl6/Grammar.pm b/src/Perl6/Grammar.pm index 6cd0123..f9a6e70 100644 --- a/src/Perl6/Grammar.pm +++ b/src/Perl6/Grammar.pm @@ -2896,7 +2896,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD { | > [ || *? \s > ] # dwim on "$foo." - [ || <.panic: "Quoted method name requires parenthesized arguments"> ] + [ || <.panic: "Quoted method name requires parenthesized arguments. If you meant to concatenate two strings, use '~'."> ] ] <.unsp>? :dba('method arguments') [ @@ -3008,6 +3008,7 @@ grammar Perl6::Grammar is HLL::Grammar does STD { token infix:sym { >> } token infix:sym<~> { } + token infix:sym<.> { '.' <[\]\)\},:\s\$"']> <.obs('. to concatenate strings', '~')> } token infix:sym<&> { } token infix:sym<|> { } -- 1.7.10.4 ```
p6rt commented 11 years ago

The RT System itself - Status changed from 'new' to 'open'

p6rt commented 11 years ago

From @moritz

Thanks, I've applied your patch, with a small modification​:

instead of + token infix​:sym\<.> { '.' \<[\]\)\},​:\s\$"']>
I've used \, as all the other operators do​: + token infix​:sym\<.> { \ \<[\]\)\},​:\s\$"']>

I'm wondering, if a testcase should be written to check for a helpful error message? Would this kind of thing go in t/spec somehow?

I've added one to t/spec/S32-exceptions/misc.t that checks for X​::Obsolete.

As for the other one, the proper way to test it is to change it to a typed exception, and check for the type.

Cheers, Moritz

p6rt commented 11 years ago

@moritz - Status changed from 'open' to 'resolved'