This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 230553 - Returning associative array always a compiler error
Summary: Returning associative array always a compiler error
Status: RESOLVED INVALID
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P2 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-30 21:06 UTC by _ gtzabari
Modified: 2013-06-03 06:24 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2013-05-30 21:06:49 UTC
Product Version: NetBeans IDE Dev (Build 201305292301)
Java: 1.7.0_21; Java HotSpot(TM) 64-Bit Server VM 23.21-b01
Runtime: Java(TM) SE Runtime Environment 1.7.0_21-b11
System: Windows 7 version 6.1 running on amd64; Cp1252; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev

1. This code compiles fine:

function method()
{
	var test =
		{
			first: second,
			third: forth
		};
}

2. But this code is highlighted as an error:

function method()
{
	return
		{
			first: second,
			third: forth
		};
}

3. The error message is: 

test.js:6:8 Expected ; but found :
			third: forth
			     ^
----
(Alt-Enter shows hints)

4. I'm flagging this as a P2 because it is a regression for a fairly common use-case.
Comment 1 Vladimir Riha 2013-05-31 07:27:57 UTC
It is because of "{" of the object literal is on new line, following is OK


function method()
{
    return {
        first: second,
        third: forth
    };
}

Does the your function actually work? I'm just curious because it doesn't for me in Chrome & Firefox and according to [1], there should be no line terminator between return keyword and value/statement


[1] http://www.ecma-international.org/ecma-262/5.1/#sec-12.9
Comment 2 _ gtzabari 2013-05-31 16:05:17 UTC
Wow, that's terrible :) Okay, in that case I would like Netbeans to provide a hint of what is wrong.

Can you change the compiler error to "Newline not allowed between return and expression. See http://www.ecma-international.org/ecma-262/5.1/#sec-12.9"?
Comment 3 Vladimir Riha 2013-06-03 06:24:06 UTC
I filled enhancement for it and added you to CC (issue 230638). Thank you