Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
p6rt opened this issue Sep 14, 2010 · 6 comments
Closed

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

p6rt opened this issue Sep 14, 2010 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Sep 14, 2010

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

Searchable as RT77856$

@p6rt
Copy link
Author

p6rt commented Sep 14, 2010

From @masak

<masak> std​: "foo" . "bar"
<p6eval> std 32123​: OUTPUT«�[31m===�[0mSORRY!�[31m===�[0m␤Unsupported
use of . to concatenate strings; in Perl 6 please use ~ [...] Parse
failed␤FAILED 00​:01 115m␤»
<masak> rakudo​: "foo" . "bar"
<p6eval> rakudo c71489​: OUTPUT«===SORRY!===␤Confused [...]
* masak submits LTA rakudobug

@p6rt
Copy link
Author

p6rt commented Dec 13, 2012

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
Copy link
Author

p6rt commented Dec 13, 2012

From @timo

0001-warn-about-obsolete-use-of-.-to-concatenate-strings.patch
From 1d8320e1037855e9a90f987ec6649cc73247e60d Mon Sep 17 00:00:00 2001
From: Timo Paulssen <timonator@perpetuum-immobile.de>
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 {
         | <?before <[ ' " ]> >
             [ <!{$*QSIGIL}> || <!before '"' <-["]>*? \s > ] # dwim on "$foo."
             <quote>
-            [ <?before '(' | '.(' | '\\'> || <.panic: "Quoted method name requires parenthesized arguments"> ]
+            [ <?before '(' | '.(' | '\\'> || <.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<xx>    { <sym> >> <O('%replication')> }
 
     token infix:sym<~>    { <sym>  <O('%concatenation')> }
+    token infix:sym<.>    { '.' <[\]\)\},:\s\$"']>  <.obs('. to concatenate strings', '~')> }
 
     token infix:sym<&>    { <sym> <O('%junctive_and')> }
     token infix:sym<|>    { <sym> <O('%junctive_or')> }
-- 
1.7.10.4

@p6rt
Copy link
Author

p6rt commented Dec 13, 2012

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

@p6rt
Copy link
Author

p6rt commented Dec 13, 2012

From @moritz

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

instead of
+ token infix​:sym<.> { '.' <[\]\)\},​:\s\$"']>
I've used <sym>, as all the other operators do​:
+ token infix​:sym<.> { <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
Copy link
Author

p6rt commented Dec 13, 2012

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

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

No branches or pull requests

1 participant