[ragel-users] "declared but not used" errors with v7 Go backend

Damian Gryski dgryski at gmail.com
Thu Nov 1 09:12:32 UTC 2018


This is with ragel 7.0.0.11 and colm 0.13.0.6.  I was unable to get ragel
to build from git.

With the example grammar at github.com/dgryski/ragel-examples/regexp1, I
get the following error:

$ ragel-go sshd.rl
$ go build
# github.com/dgryski/ragel-examples/regexp1
./sshd.go:11:6: _scanner_trans_cond_spaces declared and not used
./sshd.go:12:6: _scanner_trans_offsets declared and not used
./sshd.go:13:6: _scanner_trans_lengths declared and not used
./sshd.go:14:6: _scanner_cond_keys declared and not used
./sshd.go:17:6: _scanner_eof_cond_spaces declared and not used
./sshd.go:18:6: _scanner_eof_cond_key_offs declared and not used
./sshd.go:19:6: _scanner_eof_cond_key_lens declared and not used
./sshd.go:20:6: _scanner_eof_cond_keys declared and not used
./sshd.go:21:6: _scanner_nfa_targs declared and not used
./sshd.go:22:6: _scanner_nfa_offsets declared and not used
./sshd.go:22:6: too many errors

The usual solution to this in autogenerated code is to assign them to `_`,
the underscore "blank variable".  This satisfies the compiler and the
entire array will be eliminated as a dead-store if it ends up not being
used.

Thus, each declaration for variables which may or may not be used will look
like:
var _scanner_trans_cond_spaces [] int8  = [] int8  { ... }
_ = _scanner_trans_cond_space

Note also the first `[] int8` is redundant -- the compiler will infer the
type from the type of the array on the right hand side of the `=`.

Fixing these issues in the Go template in the src/host-go directory and
rebuilding fixed these errors (although I had to copy files from the git
checkout for the template changes to recompile successfully).

Damian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20181101/89fbb803/attachment.html>


More information about the ragel-users mailing list