Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 349781

Summary: [validation] Referencing 'arguments' in anon function within a if (false) { ... } causes validator to fail
Product: [WebTools] JSDT Reporter: andreinaspam
Component: GeneralAssignee: Chris Jaun <cmjaun>
Status: RESOLVED FIXED QA Contact: Nitin Dahyabhai <thatnitind>
Severity: normal    
Priority: P3 CC: cmjaun
Version: unspecifiedFlags: thatnitind: review+
Target Milestone: 3.2.5   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
patch none

Description andreinaspam CLA 2011-06-19 22:01:01 EDT
Build Identifier: 20110301-1815

I'm not sure what kind of error this is so I was not able to search for it.

This problem seems to happen if any statement is in the "if (...)" that would always resolve to false at build time. For example, "if (0 == 1)" also causes the validator to fail.

Doing something like "if ('a'.toLowerCase() == 'b')" will not cause the validator failure.

Using a variable set to false will also not cause the validator failure. An exmaple would be "var a = false; if (a) { ... }".

Reproducible: Always

Steps to Reproduce:
1. Created JavaScript project
2. Create JavaScript source file and insert the following code:

if (false) {
	var a = function(){
		arguments;
	};
}

3. You may need to check Project -> Build automatically.
4. Save the file.

========

Here are some related error log entries:

!ENTRY org.eclipse.core.resources 4 2 2011-06-19 21:44:46.089
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.resources".
!STACK 0
java.lang.NullPointerException

!ENTRY org.eclipse.core.resources 4 75 2011-06-19 21:44:46.090
!MESSAGE Errors occurred during the build.
!SUBENTRY 1 org.eclipse.wst.jsdt.core 4 75 2011-06-19 21:44:46.090
!MESSAGE Errors running builder 'JavaScript Validator' on project 'Test'.
!STACK 0
java.lang.NullPointerException

!ENTRY org.eclipse.wst.jsdt.core 4 4 2011-06-19 21:44:46.222
!MESSAGE Exception occurred during problem detection:
----------------------------------- SOURCE BEGIN -------------------------------------
if (false) {
	var a = function(){
		arguments;
	};
}

----------------------------------- SOURCE END -------------------------------------
!STACK 0
java.lang.NullPointerException

!ENTRY org.eclipse.wst.jsdt.ui 4 0 2011-06-19 21:44:46.222
!MESSAGE Error in JSDT Core during reconcile
!STACK 1
JavaScript Model Exception: java.lang.NullPointerException
	at org.eclipse.wst.jsdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:298)
	at org.eclipse.wst.jsdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:320)
	at org.eclipse.wst.jsdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:197)
	at org.eclipse.wst.jsdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:96)
	at org.eclipse.wst.jsdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:742)
	at org.eclipse.wst.jsdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:802)
	at org.eclipse.wst.jsdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1202)
	at org.eclipse.wst.jsdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:95)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.wst.jsdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:76)
	at org.eclipse.wst.jsdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:143)
	at org.eclipse.wst.jsdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:85)
	at org.eclipse.wst.jsdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:94)
	at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
	at org.eclipse.wst.jsdt.internal.ui.text.JavaReconciler.process(JavaReconciler.java:371)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
Caused by: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
!SUBENTRY 1 org.eclipse.wst.jsdt.core 4 1005 2011-06-19 21:44:46.223
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException

!ENTRY org.eclipse.wst.jsdt.ui 4 2 2011-06-19 21:46:06.385
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.wst.jsdt.ui".
!STACK 0
java.lang.NullPointerException

!ENTRY org.eclipse.wst.jsdt.ui 4 0 2011-06-19 21:46:06.386
!MESSAGE Error in JSDT Core during AST creation
!STACK 0
java.lang.NullPointerException

!ENTRY org.eclipse.core.resources 4 2 2011-06-19 21:46:08.761
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.resources".
!STACK 0
java.lang.NullPointerException

!ENTRY org.eclipse.core.resources 4 75 2011-06-19 21:46:08.762
!MESSAGE Errors occurred during the build.
!SUBENTRY 1 org.eclipse.wst.jsdt.core 4 75 2011-06-19 21:46:08.762
!MESSAGE Errors running builder 'JavaScript Validator' on project 'Test'.
!STACK 0
java.lang.NullPointerException

!ENTRY org.eclipse.wst.jsdt.core 4 4 2011-06-19 21:46:08.868
!MESSAGE Exception occurred during problem detection:
----------------------------------- SOURCE BEGIN -------------------------------------
if (false) {
	var a = function(){
		arguments;
	};
}

----------------------------------- SOURCE END -------------------------------------
!STACK 0
java.lang.NullPointerException

!ENTRY org.eclipse.wst.jsdt.ui 4 0 2011-06-19 21:46:08.868
!MESSAGE Error in JSDT Core during reconcile
!STACK 1
JavaScript Model Exception: java.lang.NullPointerException
	at org.eclipse.wst.jsdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:298)
	at org.eclipse.wst.jsdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:320)
	at org.eclipse.wst.jsdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:197)
	at org.eclipse.wst.jsdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:96)
	at org.eclipse.wst.jsdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:742)
	at org.eclipse.wst.jsdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:802)
	at org.eclipse.wst.jsdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1202)
	at org.eclipse.wst.jsdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:95)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.wst.jsdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:76)
	at org.eclipse.wst.jsdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:143)
	at org.eclipse.wst.jsdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:85)
	at org.eclipse.wst.jsdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:94)
	at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:77)
	at org.eclipse.wst.jsdt.internal.ui.text.JavaReconciler.process(JavaReconciler.java:371)
	at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:206)
Caused by: java.lang.NullPointerException
Caused by: java.lang.NullPointerException
!SUBENTRY 1 org.eclipse.wst.jsdt.core 4 1005 2011-06-19 21:46:08.869
!MESSAGE java.lang.NullPointerException
!STACK 0
java.lang.NullPointerException
Comment 1 Chris Jaun CLA 2011-06-24 10:14:21 EDT
Created attachment 198535 [details]
patch

Should not do flow checking if we are looking at the arguments variable in the method scope.
Comment 2 Chris Jaun CLA 2011-07-01 10:45:25 EDT
Checked into 3.2.5 and HEAD.