user5311: Supposed I have a validator below, checking only if the output value is locked by the same script.
{-# INLINEABLE mkValidator #-}
mkValidator :: TestingParam -> TestingDatum -> TestingRedeemer -> ScriptContext -> Bool
mkValidator param _ red ctx = case red of
  (MergeScript anotherParam) -> 
    traceIfFalse "Script provided is incorrect" (valueLockedBy info (valHash anotherParam) == txOutValue ownInput)
  _ -> False
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    ownInput :: TxOut
    ownInput = case findOwnInput ctx of
      Nothing -> traceError "input missing"
      Just i -> txInInfoResolved i

{-# INLINABLE typedValidator #-}
typedValidator :: TestingParam -> Scripts.TypedValidator TestingScript
typedValidator param =
  Scripts.mkTypedValidator @TestingScript
    ($$(PlutusTx.compile [||mkValidator||]) `PlutusTx.applyCode` PlutusTx.liftCode param)
    $$(PlutusTx.compile [||wrap||])
  where
    wrap = Scripts.wrapValidator @TestingDatum @TestingRedeemer

{-# INLINABLE validator #-}
validator :: TestingParam -> Validator
validator = Scripts.validatorScript . typedValidator

{-# INLINABLE valHash #-}
valHash :: TestingParam -> Ledger.ValidatorHash
valHash = Scripts.validatorHash . typedValidator

However, it then throws the error GHC Core to PLC plugin: E043:Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function: Variable OtherScripts.Testing.ReferenceTesting.valHash.
Another similar issue with supplying minting policy here:
Using `curSymbol` function in Validator script
Looked at several sources and stuck with this issue for months. Can someone advises me if it is a dead end current Plutus ability?
If so, happy to see if someone is interested in drafting a CIP for this together, since allowing to use mkValidator or mkMintingPolicy script externally allows another level of scripts composibility which I think is essential for Cardano smart contract to get into mainstream. Also, this would enable scripts to be composed more secured as validator could know the identity of other scripts they are interacting with, instead of just hardcoding-supplying a validator hash externally.

user7225: Script.validatorHash can not be compiled to Plutus Core (probably for good reason, as it would've resulted in much larger on-chain scripts).
As Erik mentioned, if you only need the hash of your current validator, ownHash is the answer. But if you want to recreate the validator hash of another script on the fly, that's not possible.
A typical solution is to provide this desired validator hash as a parameter to your current script, and therefore make it "aware" of your other script.

user6291: In this case, when compiling your validator, compiler is trying to compute a value (which is only available after successfully compiled your validator) to complete compiling your validator, thus, it's impossible case.
Your validator is parameterized validator so with each different parameter, it's different validator with different validator hash.
If you want to get outputs of the same validator with same parameter then, that's same validator with same validator hash so there is a getContinuingOutputs function you can use or findContinuingOutputs if you are only interested in amount. Also ownHash is available for getting the validator hash within the same validator.
If it's the case that you want to check an output is locked by the same validator but with different parameter, then it's no longer same validator, it's a completely different validator with different validator hash even if the source code is the same. In this case, you probably might want to provide validator hash directly to the validator via datum or redeemer rather than providing the different parameter which is not possible to compute hash from.

5311: <p>Supposed I have a validator below, checking only if the output value is locked by the same script.</p>
<pre class="lang-haskell prettyprint-override"><code>{-# INLINEABLE mkValidator #-}
mkValidator :: TestingParam -&gt; TestingDatum -&gt; TestingRedeemer -&gt; ScriptContext -&gt; Bool
mkValidator param _ red ctx = case red of
  (MergeScript anotherParam) -&gt; 
    traceIfFalse &quot;Script provided is incorrect&quot; (valueLockedBy info (valHash anotherParam) == txOutValue ownInput)
  _ -&gt; False
  where
    info :: TxInfo
    info = scriptContextTxInfo ctx

    ownInput :: TxOut
    ownInput = case findOwnInput ctx of
      Nothing -&gt; traceError &quot;input missing&quot;
      Just i -&gt; txInInfoResolved i

{-# INLINABLE typedValidator #-}
typedValidator :: TestingParam -&gt; Scripts.TypedValidator TestingScript
typedValidator param =
  Scripts.mkTypedValidator @TestingScript
    ($$(PlutusTx.compile [||mkValidator||]) `PlutusTx.applyCode` PlutusTx.liftCode param)
    $$(PlutusTx.compile [||wrap||])
  where
    wrap = Scripts.wrapValidator @TestingDatum @TestingRedeemer

{-# INLINABLE validator #-}
validator :: TestingParam -&gt; Validator
validator = Scripts.validatorScript . typedValidator

{-# INLINABLE valHash #-}
valHash :: TestingParam -&gt; Ledger.ValidatorHash
valHash = Scripts.validatorHash . typedValidator
</code></pre>
<p>However, it then throws the error <code>GHC Core to PLC plugin: E043:Error: Reference to a name which is not a local, a builtin, or an external INLINABLE function: Variable OtherScripts.Testing.ReferenceTesting.valHash</code>.</p>
<p>Another similar issue with supplying minting policy here:
<a href="https://cardano.stackexchange.com/questions/8327/using-cursymbol-function-in-validator-script">Using `curSymbol` function in Validator script</a></p>
<p>Looked at several sources and stuck with this issue for months. Can someone advises me if it is a dead end current Plutus ability?</p>
<p>If so, happy to see if someone is interested in drafting a CIP for this together, since allowing to use <code>mkValidator</code> or <code>mkMintingPolicy</code> script externally allows another level of scripts composibility which I think is essential for Cardano smart contract to get into mainstream. Also, this would enable scripts to be composed more secured as validator could know the identity of other scripts they are interacting with, instead of just hardcoding-supplying a validator hash externally.</p>
 7225: <p><code>Script.validatorHash</code> can not be compiled to Plutus Core (probably for good reason, as it would've resulted in much larger on-chain scripts).</p>
<p><a href="https://cardano.stackexchange.com/a/9007/7225">As Erik mentioned</a>, if you only need the hash of your current validator, <code>ownHash</code> is the answer. But if you want to recreate the validator hash of another script on the fly, that's not possible.</p>
<p>A typical solution is to provide this desired validator hash as a parameter to your current script, and therefore make it &quot;aware&quot; of your other script.</p>
 6291: <p>In this case, when compiling your validator, compiler is trying to compute a value (which is only available after successfully compiled your validator) to complete compiling your validator, thus, it's impossible case.</p>
<p>Your validator is parameterized validator so with each different parameter, it's different validator with different validator hash.</p>
<p>If you want to get outputs of the same validator with same parameter then, that's same validator with same validator hash so there is a <code>getContinuingOutputs</code> function you can use or <code>findContinuingOutputs</code> if you are only interested in amount. Also <code>ownHash</code> is available for getting the validator hash within the same validator.</p>
<p>If it's the case that you want to check an output is locked by the same validator but with different parameter, then it's no longer same validator, it's a completely different validator with different validator hash even if the source code is the same. In this case, you probably might want to provide validator hash directly to the validator via datum or redeemer rather than providing the different parameter which is not possible to compute hash from.</p>
