9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Bengt Kleberg <eleberg@cbe.ericsson.se>
To: 9fans@cse.psu.edu
Subject: [9fans] Inferno, Limbo unexpectancies
Date: Thu, 14 Feb 2002 16:05:15 +0100	[thread overview]
Message-ID: <200202141505.g1EF5FP01844@cbe.ericsson.se> (raw)

With the Inferno mail list down I hope to reach 'the right people' here at 
9fans.

If Inferno related emails are considered bandwith waisting, please let me know 
and I will stop.

I have stumbled upon 2 things in Limbo that I would like to warn about 
(presumably somebody else is as stupid as I am :-)


1 Unintended variable shadowing:

n := 3
while (n > 0) {
	n:= n - 1; # i know of n--, but this is an example
}


as is obvious (afterwards), n will never reach 0.
i really think the compiler should warn about this.



2 No array bounds checking (only for JIT):

The below program will crash at the return statement in crash(), not in the 
for() loop. Moreover, this only happens when using JIT.


bengt

implement Crash;

include "draw.m";
include "sys.m";
	sys: Sys;


Crash: module {
	init:	fn(nil: ref Draw->Context, args: list of string);
};

init(nil: ref Draw->Context, args: list of string) {
	sys = load Sys Sys->PATH;

	a:= crash(  );
	
	return;
}

crash(  ): array of byte {
	result:= array [1] of byte;

	for (i:= 0; i < 10; i++) {
		sys->print( "%d\n", i );
		result[i] = byte 0;
		sys->print( "%d\n", len result );
	}

	return result[:5];
}




             reply	other threads:[~2002-02-14 15:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-14 15:05 Bengt Kleberg [this message]
2002-02-14 15:40 forsyth
2002-02-18 10:13 ` Maarit Maliniemi
2002-02-14 15:43 forsyth
2002-02-15  0:48 ` Sam Ducksworth
2002-02-15 12:52 Bengt Kleberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200202141505.g1EF5FP01844@cbe.ericsson.se \
    --to=eleberg@cbe.ericsson.se \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).