#31192

x.executor: JobFn type alias collides with x.async.JobFn when both modules are imported

Openmetif12opened 4d ago

Description

When a program imports both \x.executor\ and \x.async, compilation fails:

\
vlib/x/executor/submit.v:16:3: error: cannot assign to field \ : expected \ n (mut context.Context) !, not \ n () !void
\\

Root cause

Both modules declare a type alias named \JobFn:

  • \x.executor.JobFn = fn () !\
  • \x.async.JobFn = fn (mut context.Context) !\

During the transform stage, \executor.ExecutorJob.f\ (typed \JobFn) gets resolved to \sync.JobFn\ instead of \executor.JobFn. This is a type resolution collision in the transform's type cache or name resolution.

Reproduction

\\ import x.executor import x.async as xasync

fn main() { _ = xasync.background mut e := executor.new(queue_size: 2)! e.try_post(fn () ! {})! println('ok') } \\

Fix

PR #31191 inlines the concrete signature \ n () !\ in the \ExecutorJob\ struct field instead of using the \JobFn\ alias, removing the indirection that caused the collision.

Note

This is a workaround fix. The underlying compiler issue (type alias collision across modules in the transform stage) may still affect other code.

Activity

0

No activity yet.