Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #39441 > unrolled thread

Bug in javascript found

Started byJonas Thörnvall <jonas.thornvall@gmail.com>
First post2021-02-09 12:42 -0800
Last post2021-02-14 10:38 +0100
Articles 12 — 5 participants

Back to article view | Back to comp.lang.javascript


Contents

  Bug in javascript found Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-02-09 12:42 -0800
    Re: Bug in javascript found Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-02-09 12:43 -0800
    Re: Bug in javascript found Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-02-09 21:01 +0000
    Re: Bug in javascript found Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-02-09 13:03 -0800
      Re: Bug in javascript found Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-02-09 13:14 -0800
        Re: Bug in javascript found Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-02-10 02:16 +0000
          Re: Bug in javascript found Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-02-10 01:11 -0800
            Re: Bug in javascript found Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-02-10 11:20 +0000
    Re: Bug in javascript found Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-02-14 00:52 +0100
      Re: Bug in javascript found Jonas Thörnvall <jonas.thornvall@gmail.com> - 2021-02-13 16:32 -0800
      Re: Bug in javascript found John G Harris <niam@jghnorth.org.uk.invalid> - 2021-02-14 10:22 +0000
    Re: Bug in javascript found Silvio <silvio@internet.com> - 2021-02-14 10:38 +0100

#39441 — Bug in javascript found

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2021-02-09 12:42 -0800
SubjectBug in javascript found
Message-ID<ad443096-b466-4cdc-a0f8-edc0d815fa5en@googlegroups.com>
The input alert have not same value as the calcSTR alert.
And that is also why it not goes into the if clause.

The "Input"+calcSTR is +7
but  the "calcSTR"+calcSTR is +14-7

A string can't just change value so there must be a bug in at least Chrome implementation of javascript.

function evalSecondary(calcSTR){
	alert("Input"+calcSTR);
	for(m=0;m<calcSTR.length;m++){
	tempChar=calcSTR.charCodeAt(m);
		//Plus or Minus
		if((tempChar==43|| tempChar==45) && m!=0){
		    alert("tempChar "+tempChar+ " M="+m+" calcSTR"+calcSTR);
			operand=calcSTR.charAt(m);
			getSecondaryOps(calcSTR);
			calcSubSecondary(calcSTR);
		} 
	}
}

[toc] | [next] | [standalone]


#39442

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2021-02-09 12:43 -0800
Message-ID<93119ebe-e0e6-4bde-a5de-b1170fa65b19n@googlegroups.com>
In reply to#39441
tisdag 9 februari 2021 kl. 21:42:46 UTC+1 skrev Jonas Thörnvall:
> The input alert have not same value as the calcSTR alert. 
> And that is also why it not goes into the if clause. 
> 
> The "Input"+calcSTR is +7 
> but the "calcSTR"+calcSTR is +14-7 
> 
> A string can't just change value so there must be a bug in at least Chrome implementation of javascript. 
> 
> function evalSecondary(calcSTR){ 
> alert("Input"+calcSTR); 
> for(m=0;m<calcSTR.length;m++){ 
> tempChar=calcSTR.charCodeAt(m); 
> //Plus or Minus 
> if((tempChar==43|| tempChar==45) && m!=0){ 
> alert("tempChar "+tempChar+ " M="+m+" calcSTR"+calcSTR); 
> operand=calcSTR.charAt(m); 
> getSecondaryOps(calcSTR); 
> calcSubSecondary(calcSTR); 
> } 
> } 
> }
Sorry "that is why it goes into the if clause"

[toc] | [prev] | [next] | [standalone]


#39443

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2021-02-09 21:01 +0000
Message-ID<87pn19hs6i.fsf@bsb.me.uk>
In reply to#39441
Jonas Thörnvall <jonas.thornvall@gmail.com> writes:

> The input alert have not same value as the calcSTR alert.
> And that is also why it not goes into the if clause.
>
> The "Input"+calcSTR is +7
> but  the "calcSTR"+calcSTR is +14-7
>
> A string can't just change value so there must be a bug in at least
> Chrome implementation of javascript.
>
> function evalSecondary(calcSTR){
> 	alert("Input"+calcSTR);
> 	for(m=0;m<calcSTR.length;m++){
> 	tempChar=calcSTR.charCodeAt(m);
> 		//Plus or Minus
> 		if((tempChar==43|| tempChar==45) && m!=0){
> 		    alert("tempChar "+tempChar+ " M="+m+" calcSTR"+calcSTR);
> 			operand=calcSTR.charAt(m);
> 			getSecondaryOps(calcSTR);
> 			calcSubSecondary(calcSTR);
> 		} 
> 	}
> }

You need to post a small, complete example that demonstrates the
problem.  You are still using what I'd loosely describe as global
variables and that makes you code one giant interconnected web of
potential side-effects.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#39444

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2021-02-09 13:03 -0800
Message-ID<7ad3dfb3-90b3-4fce-b537-55511a64cea8n@googlegroups.com>
In reply to#39441
tisdag 9 februari 2021 kl. 21:42:46 UTC+1 skrev Jonas Thörnvall:
> The input alert have not same value as the calcSTR alert. 
> And that is also why it not goes into the if clause. 
> 
> The "Input"+calcSTR is +7 
> but the "calcSTR"+calcSTR is +14-7 
> 
> A string can't just change value so there must be a bug in at least Chrome implementation of javascript. 
> 
> function evalSecondary(calcSTR){ 
> alert("Input"+calcSTR); 
> for(m=0;m<calcSTR.length;m++){ 
> tempChar=calcSTR.charCodeAt(m); 
> //Plus or Minus 
> if((tempChar==43|| tempChar==45) && m!=0){ 
> alert("tempChar "+tempChar+ " M="+m+" calcSTR"+calcSTR); 
> operand=calcSTR.charAt(m); 
> getSecondaryOps(calcSTR); 
> calcSubSecondary(calcSTR); 
> } 
> } 
> }
Well you see the code creating the alerts.
https://jonasth.github.io/Mathparse/INDEX.HTML
It is an impossibility frankly.

[toc] | [prev] | [next] | [standalone]


#39445

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2021-02-09 13:14 -0800
Message-ID<6c7176b7-13fe-4381-8083-ccc58fc4fcb6n@googlegroups.com>
In reply to#39444
tisdag 9 februari 2021 kl. 22:03:22 UTC+1 skrev Jonas Thörnvall:
> tisdag 9 februari 2021 kl. 21:42:46 UTC+1 skrev Jonas Thörnvall:
> > The input alert have not same value as the calcSTR alert. 
> > And that is also why it not goes into the if clause. 
> > 
> > The "Input"+calcSTR is +7 
> > but the "calcSTR"+calcSTR is +14-7 
> > 
> > A string can't just change value so there must be a bug in at least Chrome implementation of javascript. 
> > 
> > function evalSecondary(calcSTR){ 
> > alert("Input"+calcSTR); 
> > for(m=0;m<calcSTR.length;m++){ 
> > tempChar=calcSTR.charCodeAt(m); 
> > //Plus or Minus 
> > if((tempChar==43|| tempChar==45) && m!=0){ 
> > alert("tempChar "+tempChar+ " M="+m+" calcSTR"+calcSTR); 
> > operand=calcSTR.charAt(m); 
> > getSecondaryOps(calcSTR); 
> > calcSubSecondary(calcSTR); 
> > } 
> > } 
> > }
> Well you see the code creating the alerts. 
> https://jonasth.github.io/Mathparse/INDEX.HTML 
> It is an impossibility frankly.
I simply could not understand why the recursion never ended, but then again if a variable can change value "within same function" while not assigned between two alerts then something definitely broken.

[toc] | [prev] | [next] | [standalone]


#39446

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2021-02-10 02:16 +0000
Message-ID<878s7wis65.fsf@bsb.me.uk>
In reply to#39445
Jonas Thörnvall <jonas.thornvall@gmail.com> writes:

> tisdag 9 februari 2021 kl. 22:03:22 UTC+1 skrev Jonas Thörnvall:
>> tisdag 9 februari 2021 kl. 21:42:46 UTC+1 skrev Jonas Thörnvall:
>> > The input alert have not same value as the calcSTR alert. 
>> > And that is also why it not goes into the if clause. 
>> > 
>> > The "Input"+calcSTR is +7 
>> > but the "calcSTR"+calcSTR is +14-7 
>> > 
>> > A string can't just change value so there must be a bug in at least Chrome implementation of javascript. 
>> > 
>> > function evalSecondary(calcSTR){ 
>> > alert("Input"+calcSTR); 
>> > for(m=0;m<calcSTR.length;m++){ 
>> > tempChar=calcSTR.charCodeAt(m); 
>> > //Plus or Minus 
>> > if((tempChar==43|| tempChar==45) && m!=0){ 
>> > alert("tempChar "+tempChar+ " M="+m+" calcSTR"+calcSTR); 
>> > operand=calcSTR.charAt(m); 
>> > getSecondaryOps(calcSTR); 
>> > calcSubSecondary(calcSTR);
>> > } 
>> > } 
>> > }
>> Well you see the code creating the alerts. 
>> https://jonasth.github.io/Mathparse/INDEX.HTML 
>> It is an impossibility frankly.
> I simply could not understand why the recursion never ended, but then
> again if a variable can change value "within same function" while not
> assigned between two alerts then something definitely broken.

It is not going to turn out to be Chrome that's broken.  Your code is a
mess, but the biggest problem is that you are still using global
variables.  These are always a bad idea, but they are particularly bad
in recursive code.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#39447

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2021-02-10 01:11 -0800
Message-ID<aae38420-1ff8-4d3e-adc4-12629019351an@googlegroups.com>
In reply to#39446
onsdag 10 februari 2021 kl. 03:16:10 UTC+1 skrev Ben Bacarisse:
> Jonas Thörnvall <jonas.t...@gmail.com> writes: 
> 
> > tisdag 9 februari 2021 kl. 22:03:22 UTC+1 skrev Jonas Thörnvall: 
> >> tisdag 9 februari 2021 kl. 21:42:46 UTC+1 skrev Jonas Thörnvall: 
> >> > The input alert have not same value as the calcSTR alert. 
> >> > And that is also why it not goes into the if clause. 
> >> > 
> >> > The "Input"+calcSTR is +7 
> >> > but the "calcSTR"+calcSTR is +14-7 
> >> > 
> >> > A string can't just change value so there must be a bug in at least Chrome implementation of javascript. 
> >> > 
> >> > function evalSecondary(calcSTR){ 
> >> > alert("Input"+calcSTR); 
> >> > for(m=0;m<calcSTR.length;m++){ 
> >> > tempChar=calcSTR.charCodeAt(m); 
> >> > //Plus or Minus 
> >> > if((tempChar==43|| tempChar==45) && m!=0){ 
> >> > alert("tempChar "+tempChar+ " M="+m+" calcSTR"+calcSTR); 
> >> > operand=calcSTR.charAt(m); 
> >> > getSecondaryOps(calcSTR); 
> >> > calcSubSecondary(calcSTR); 
> >> > } 
> >> > } 
> >> > } 
> >> Well you see the code creating the alerts. 
> >> https://jonasth.github.io/Mathparse/INDEX.HTML 
> >> It is an impossibility frankly. 
> > I simply could not understand why the recursion never ended, but then 
> > again if a variable can change value "within same function" while not 
> > assigned between two alerts then something definitely broken.
> It is not going to turn out to be Chrome that's broken. Your code is a 
> mess, but the biggest problem is that you are still using global 
> variables. These are always a bad idea, but they are particularly bad 
> in recursive code. 
> 
> -- 
> Ben.
So you say it is correct for a variable to change value within a function without having an assignment between the changing points, i kind of doubt that.
But i agree there is some sorcery going into recursive coding, global values that are in a function no longer present after recursion ended, my head quite spinning of it.

[toc] | [prev] | [next] | [standalone]


#39450

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2021-02-10 11:20 +0000
Message-ID<87r1logoew.fsf@bsb.me.uk>
In reply to#39447
Jonas Thörnvall <jonas.thornvall@gmail.com> writes:

> onsdag 10 februari 2021 kl. 03:16:10 UTC+1 skrev Ben Bacarisse:
>> Jonas Thörnvall <jonas.t...@gmail.com> writes: 
>> 
>> > tisdag 9 februari 2021 kl. 22:03:22 UTC+1 skrev Jonas Thörnvall: 
>> >> tisdag 9 februari 2021 kl. 21:42:46 UTC+1 skrev Jonas Thörnvall: 
>> >> > The input alert have not same value as the calcSTR alert. 
>> >> > And that is also why it not goes into the if clause. 
>> >> > 
>> >> > The "Input"+calcSTR is +7 
>> >> > but the "calcSTR"+calcSTR is +14-7 
>> >> > 
>> >> > A string can't just change value so there must be a bug in at least Chrome implementation of javascript. 
>> >> > 
>> >> > function evalSecondary(calcSTR){ 
>> >> > alert("Input"+calcSTR); 
>> >> > for(m=0;m<calcSTR.length;m++){ 
>> >> > tempChar=calcSTR.charCodeAt(m); 
>> >> > //Plus or Minus 
>> >> > if((tempChar==43|| tempChar==45) && m!=0){ 
>> >> > alert("tempChar "+tempChar+ " M="+m+" calcSTR"+calcSTR); 
>> >> > operand=calcSTR.charAt(m); 
>> >> > getSecondaryOps(calcSTR); 
>> >> > calcSubSecondary(calcSTR); 
>> >> > } 
>> >> > } 
>> >> > } 
>> >> Well you see the code creating the alerts. 
>> >> https://jonasth.github.io/Mathparse/INDEX.HTML 
>> >> It is an impossibility frankly. 
>> > I simply could not understand why the recursion never ended, but then 
>> > again if a variable can change value "within same function" while not 
>> > assigned between two alerts then something definitely broken.
>> It is not going to turn out to be Chrome that's broken. Your code is a 
>> mess, but the biggest problem is that you are still using global 
>> variables. These are always a bad idea, but they are particularly bad 
>> in recursive code. 
>> 
> So you say it is correct for a variable to change value within a
> function without having an assignment between the changing points, i
> kind of doubt that.

Global variables can be assigned from anywhere.  The chances are your
code is changing the variable but you don't know where that is
happening.

> But i agree there is some sorcery going into recursive coding, global
> values that are in a function no longer present after recursion ended,
> my head quite spinning of it.

That feeling is common (every student I've ever taught programming to
has at some point thought that magic was involved) but it does not help.
Your code is not doing what you think it is doing and the more you focus
on other factors like supposed bugs in Chrome or sorcery the longer it
will take you to understand what you code /is/ really doing.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#39464

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2021-02-14 00:52 +0100
Message-ID<2568145.mvXUDI8C0e@PointedEars.de>
In reply to#39441
Jonas Thörnvall wrote:

> […]

<http://www.catb.org/~esr/faqs/smart-questions.html#idm368>

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

[toc] | [prev] | [next] | [standalone]


#39465

FromJonas Thörnvall <jonas.thornvall@gmail.com>
Date2021-02-13 16:32 -0800
Message-ID<e8dd4727-2c08-400f-9bd7-d7240ec920b8n@googlegroups.com>
In reply to#39464
söndag 14 februari 2021 kl. 00:52:25 UTC+1 skrev Thomas 'PointedEars' Lahn:
> Jonas Thörnvall wrote: 
> 
> > […] 
> 
> <http://www.catb.org/~esr/faqs/smart-questions.html#idm368> 
> 
> -- 
> PointedEars 
> FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix> 
> <https://github.com/PointedEars> | <http://PointedEars.de/wsvn/> 
> Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.
No the bug is there i just sidestepped it, almost drove me nuts LoL.
https://jonasth.github.io/Mathparse/INDEX.HTML

[toc] | [prev] | [next] | [standalone]


#39469

FromJohn G Harris <niam@jghnorth.org.uk.invalid>
Date2021-02-14 10:22 +0000
Message-ID<9fuh2g194ttrdn8p1fp6mlu2c05ef9kp6v@4ax.com>
In reply to#39464
On Sun, 14 Feb 2021 00:52:18 +0100, Thomas 'PointedEars' Lahn
<PointedEars@web.de> wrote:

>Jonas Thörnvall wrote:
>
>> […]

No he didn't.

  <snip>

  John

[toc] | [prev] | [next] | [standalone]


#39468

FromSilvio <silvio@internet.com>
Date2021-02-14 10:38 +0100
Message-ID<6028efa2$0$32360$e4fe514c@newszilla.xs4all.nl>
In reply to#39441
On 2/9/21 9:42 PM, Jonas Thörnvall wrote:
> The input alert have not same value as the calcSTR alert.
> And that is also why it not goes into the if clause.
> 
> The "Input"+calcSTR is +7
> but  the "calcSTR"+calcSTR is +14-7
> 
> A string can't just change value so there must be a bug in at least Chrome implementation of javascript.
> 
> function evalSecondary(calcSTR){
> 	alert("Input"+calcSTR);
> 	for(m=0;m<calcSTR.length;m++){
> 	tempChar=calcSTR.charCodeAt(m);
> 		//Plus or Minus
> 		if((tempChar==43|| tempChar==45) && m!=0){
> 		    alert("tempChar "+tempChar+ " M="+m+" calcSTR"+calcSTR);
> 			operand=calcSTR.charAt(m);
> 			getSecondaryOps(calcSTR);
> 			calcSubSecondary(calcSTR);
> 		}
> 	}
> }
> 

Thank you for pointing that out. The world has gone crazy these past 
years wondering what was wrong.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web