This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
[Bug translator/16097] improve error message on array type mismatch
- From: "jlebon at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: systemtap at sourceware dot org
- Date: Wed, 06 Nov 2013 17:56:08 +0000
- Subject: [Bug translator/16097] improve error message on array type mismatch
- Auto-submitted: auto-generated
- References: <bug-16097-6586 at http dot sourceware dot org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=16097
--- Comment #5 from Jonathan Lebon <jlebon at redhat dot com> ---
There are two simple ways to fix this:
(Patch 1) Disable mismatch detection between the expected type (t) and the
referent type (te_type). This gives the chance for the referrer type (re_type)
to be resolved as type t (see the next else-if) and thus catch possible
mismatches later between re_type/te_type, at which point we
will print the referrer token.
(Patch 2) (My personal choice) Short-circuit the logic above and pass re_tok
instead of te_tok. This also makes intuitive sense. The mismatch occurs between
te_tok and t. In other words, this means that the type we expected the
var/symbol usage (referrer) to be does not match the type
of the referent (where it was first declared/used). Upon such a mismatch, a
more helpful hint to the user would be to point to the location where we
expected the var/symbol usage to be a certain type (re_tok), rather than
printing where it was declared (te_tok).
BTW, here's another simple example that would benefit from this:
function func() {
return "string"
}
probe begin {
mylocal = 1
mylocal = func()
println(mylocal)
}
Here, we get an error like this:
semantic error: type mismatch (long vs. string): identifier 'array' at
<input>:4:1
source: array = 42
^
semantic error: type was first inferred here (string): identifier 'array' at
:4:1
source: array = 42
^
With patch 2 above:
semantic error: type mismatch (long vs. string): identifier 'array' at
<input>:5:1
source: array = func()
^
semantic error: type was first inferred here (string): identifier 'array' at
:4:1
source: array = 42
^
--
You are receiving this mail because:
You are the assignee for the bug.