# Odd error

**URL:** <https://rubytalk.org/t/odd-error/42061>\
**Category:** ruby-talk\
**Created:** [9 November 2007 23:13 UTC](https://rubytalk.org/t/odd-error/42061 "2007-11-09T23:13:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roger\_Pack4](https://avatars.discourse-cdn.com/v4/letter/r/bb73d2/32.png) [@Roger\_Pack4](https://rubytalk.org/u/Roger_Pack4)\
**Post date:** [9 November 2007 23:13 UTC](https://rubytalk.org/t/odd-error/42061/1 "2007-11-09T23:13:29Z")

</div>

irb(main):006:0\> {}.merge {:a =\> 3}  
SyntaxError: compile error  
(irb):6: syntax error, unexpected tASSOC, expecting '}'  
{}.merge {:a =\> 3}

???  
{}.merge({:a =\> 3}) works, though. Is this a grammar problem?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Bob\_Hutchison1](https://avatars.discourse-cdn.com/v4/letter/b/9e8a1a/32.png) [@Bob\_Hutchison1](https://rubytalk.org/u/Bob_Hutchison1)\
**Post date:** [9 November 2007 23:19 UTC](https://rubytalk.org/t/odd-error/42061/2 "2007-11-09T23:19:36Z")

</div>

Ambiguity I guess.

It is taking the {:a =\> 3} as a block rather than as a hash argument (merge is defined to allow that). The parenthesis resolves the ambiguity.

Cheers,  
Bob

> **···**
>
> On 9-Nov-07, at 6:13 PM, Roger Pack wrote:
> 
> > irb(main):006:0\> {}.merge {:a =\> 3}  
> > SyntaxError: compile error  
> > (irb):6: syntax error, unexpected tASSOC, expecting '}'  
> > {}.merge {:a =\> 3}
> > 
> > ???  
> > {}.merge({:a =\> 3}) works, though. Is this a grammar problem?
> 
> ----  
> Bob Hutchison -- tumblelog at [http://www.recursive.ca/so/](http://www.recursive.ca/so/)  
> Recursive Design Inc. -- weblog at [http://www.recursive.ca/hutch](http://www.recursive.ca/hutch)  
> [http://www.recursive.ca/](http://www.recursive.ca/) -- works on [http://www.raconteur.info/cms-for-static-content/home/](http://www.raconteur.info/cms-for-static-content/home/)

---

<div class="post-metadata">

**Author:** ![Arlen\_Christian\_Mar1](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@Arlen\_Christian\_Mar1](https://rubytalk.org/u/Arlen_Christian_Mar1)\
**Post date:** [10 November 2007 00:39 UTC](https://rubytalk.org/t/odd-error/42061/3 "2007-11-10T00:39:46Z")

</div>

Hi,

> \> irb(main):006:0\> {}.merge {:a =\> 3}  
> \> SyntaxError: compile error  
> \> (irb):6: syntax error, unexpected tASSOC, expecting '}'  
> \> {}.merge {:a =\> 3}  
> \>  
> \> ???  
> \> {}.merge({:a =\> 3}) works, though. Is this a grammar problem?
> 
> Ambiguity I guess.
> 
> It is taking the {:a =\> 3} as a block rather than as a hash argument  
> (merge is defined to allow that). The parenthesis resolves the  
> ambiguity.

Right. "=\>" is the tASSOC that ruby's talking about. Since it thought  
you were having a block there, the only valid thing you could have  
after :a would be an end of block (i.e. :a is your return value).

> Cheers,  
> Bob

Arlen

> **···**
>
> On Sat, 2007-11-10 at 08:19 +0900, Bob Hutchison wrote:
> 
> > On 9-Nov-07, at 6:13 PM, Roger Pack wrote:
